2023-09-15 00:35:48 +00:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
|
|
|
|
from onnx_web.chain.blend_grid import BlendGridStage
|
2024-01-06 02:13:57 +00:00
|
|
|
from onnx_web.chain.result import ImageMetadata, StageResult
|
|
|
|
from onnx_web.params import ImageParams, Size
|
2023-09-15 00:35:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BlendGridStageTests(unittest.TestCase):
|
|
|
|
def test_stage(self):
|
|
|
|
stage = BlendGridStage()
|
2023-11-20 05:18:57 +00:00
|
|
|
sources = StageResult(
|
|
|
|
images=[
|
|
|
|
Image.new("RGB", (64, 64), "black"),
|
|
|
|
Image.new("RGB", (64, 64), "white"),
|
|
|
|
Image.new("RGB", (64, 64), "black"),
|
|
|
|
Image.new("RGB", (64, 64), "white"),
|
2024-01-06 02:13:57 +00:00
|
|
|
],
|
|
|
|
metadata=[
|
|
|
|
ImageMetadata(
|
|
|
|
ImageParams("test", "txt2img", "ddim", "test", 1.0, 25, 1),
|
|
|
|
Size(64, 64),
|
|
|
|
),
|
2023-11-20 05:18:57 +00:00
|
|
|
]
|
2024-01-06 02:13:57 +00:00
|
|
|
* 4,
|
2023-11-20 05:18:57 +00:00
|
|
|
)
|
2023-09-15 00:35:48 +00:00
|
|
|
result = stage.run(None, None, None, None, sources, height=2, width=2)
|
2024-01-06 02:13:57 +00:00
|
|
|
result.validate()
|
2023-09-15 00:35:48 +00:00
|
|
|
|
|
|
|
self.assertEqual(len(result), 5)
|
2024-01-06 02:13:57 +00:00
|
|
|
self.assertEqual(result.as_images()[-1].getpixel((0, 0)), (0, 0, 0))
|