imaginAIry/tests/test_enhancers/test_upscale_realesrgan.py
Bryce 32b5175e0e feature: better upscaling
- use face enhancement in a smarter way that doesn't blur high-res images
- use a different upscale model for composition images

**Upscaling**
RealESRGAN is great but it blurs parts of images it doesn't understand

4xUltrasharp is a finetune of RealESRGan that isn't as good but doesn't have this blurry patch problem.  This makes it more suitable to use as part of the composition/upscale process.  We still use realesrgan for any last-step upscales since it does look better.

had to write a state dict translator to use the ultrasharp model

**Face Enhancement**

We no longer enhance faces that are larger than 512 pixels. They should already have enough details and the face enhancer doesn't produce faces at high enough resolution to look good at that size.
2023-12-21 05:48:02 -08:00

14 lines
494 B
Python

from PIL import Image
from imaginairy.enhancers.upscale_realesrgan import upscale_image
from tests import TESTS_FOLDER
from tests.utils import assert_image_similar_to_expectation
def test_upscale_textured_image(filename_base_for_outputs):
img = Image.open(f"{TESTS_FOLDER}/data/sand_upscale_difficult.jpg")
upscaled_image = upscale_image(img, ultrasharp=True)
assert_image_similar_to_expectation(
upscaled_image, f"{filename_base_for_outputs}.jpg", threshold=25000
)