-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a488bf4
commit 6495a5c
Showing
9 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pytest | ||
|
||
from imgutils.data import load_image | ||
from test.testings import get_testfile | ||
|
||
|
||
@pytest.fixture() | ||
def sample_image(): | ||
yield load_image(get_testfile('surtr_logo.png'), mode='RGB', force_background='white') | ||
|
||
|
||
@pytest.fixture() | ||
def sample_image_small(sample_image): | ||
yield sample_image.resize((127, 126)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pytest | ||
from PIL import Image | ||
|
||
from imgutils.metrics import psnr | ||
from imgutils.upscale import upscale_with_cdc | ||
|
||
|
||
@pytest.mark.unittest | ||
class TestUpscaleCDC: | ||
def test_upscale_with_cdc_4x(self, sample_image): | ||
assert psnr( | ||
upscale_with_cdc(sample_image), | ||
sample_image.resize((sample_image.width * 4, sample_image.height * 4), Image.LANCZOS) | ||
) >= 34.5 | ||
|
||
def test_upscale_with_cdc_2x(self, sample_image): | ||
assert psnr( | ||
upscale_with_cdc(sample_image, model='HGSR-MHR_X2_1680'), | ||
sample_image.resize((sample_image.width * 2, sample_image.height * 2), Image.LANCZOS) | ||
) >= 35.5 | ||
|
||
def test_upscale_with_cdc_small_4x(self, sample_image_small, sample_image): | ||
assert psnr( | ||
upscale_with_cdc(sample_image_small) | ||
.resize(sample_image.size, Image.LANCZOS), | ||
sample_image, | ||
) >= 28.5 | ||
|
||
def test_upscale_with_cdc_small_2x(self, sample_image_small, sample_image): | ||
assert psnr( | ||
upscale_with_cdc(sample_image_small, model='HGSR-MHR_X2_1680') | ||
.resize(sample_image.size, Image.LANCZOS), | ||
sample_image, | ||
) >= 28.0 |