Spaces:
Running on Zero
Running on Zero
File size: 718 Bytes
b855333 9a5065c b855333 9a5065c b855333 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import pytest
from PIL import Image
import upscale
@pytest.fixture
def small_image():
return Image.new("RGB", (256, 256), color=(120, 50, 200))
def test_realesrgan_2x_produces_2x_image(small_image, monkeypatch):
"""RealESRGAN runs 4x then we scale down 0.5 → net 2x."""
def fake_run_4x(_model_path, image):
w, h = image.size
return image.resize((w * 4, h * 4), Image.LANCZOS)
monkeypatch.setattr(upscale, "_realesrgan_4x", fake_run_4x)
out = upscale.realesrgan_2x(small_image, model_path="/dev/null")
assert out.size == (512, 512)
def test_realesrgan_2x_rejects_none():
with pytest.raises(ValueError):
upscale.realesrgan_2x(None, model_path="/dev/null")
|