Skip to content

Commit

Permalink
tests: create test to compare multiple image upscalers
Browse files Browse the repository at this point in the history
  • Loading branch information
brycedrennan committed Jan 20, 2024
1 parent 37ceea3 commit f020beb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions imaginairy/enhancers/upscalers/realesrgan.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def upscale_image(img, ultrasharp=False, weights_url=None):
img = img.convert("RGB")

np_img = np.array(img, dtype=np.uint8)
upsampler_output, img_mode = realesrgan_upsampler(ultrasharp=ultrasharp, weights_url=weights_url).enhance(
np_img[:, :, ::-1]
)
upsampler_output, img_mode = realesrgan_upsampler(
ultrasharp=ultrasharp, weights_url=weights_url
).enhance(np_img[:, :, ::-1])
return Image.fromarray(upsampler_output[:, :, ::-1], mode=img_mode)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def test_upscale_textured_image(filename_base_for_outputs):
upscaled_image, f"{filename_base_for_outputs}.jpg", threshold=25000
)


@pytest.mark.skip()
def test_upscalers_difficult_images(filename_base_for_outputs):
weight_urls = [
Expand All @@ -32,7 +33,6 @@ def test_upscalers_difficult_images(filename_base_for_outputs):
"https://huggingface.co/uwg/upscaler/resolve/main/ESRGAN/4x_NMKDSuperscale_Artisoft_120000_G.pth",
"https://huggingface.co/uwg/upscaler/resolve/main/ESRGAN/4x_NMKD-Superscale-SP_178000_G.pth",
"https://huggingface.co/uwg/upscaler/resolve/main/ESRGAN/4xPSNR.pth",

]
upscale_challenges_folder = f"{TESTS_FOLDER}/data/upscale_challenges"
for img_filename in os.listdir(upscale_challenges_folder):
Expand All @@ -43,4 +43,6 @@ def test_upscalers_difficult_images(filename_base_for_outputs):
for url in weight_urls:
weights_filename = url.split("/")[-1]
upscaled_image = upscale_image(img, weights_url=url)
upscaled_image.save(f"{filename_base_for_outputs}_{img_name}_{weights_filename}.jpg")
upscaled_image.save(
f"{filename_base_for_outputs}_{img_name}_{weights_filename}.jpg"
)

0 comments on commit f020beb

Please sign in to comment.