2023-09-13 22:27:44 +00:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
|
|
|
|
from onnx_web.chain.blend_linear import BlendLinearStage
|
2023-11-19 03:35:00 +00:00
|
|
|
from onnx_web.chain.result import StageResult
|
2023-09-13 22:27:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BlendLinearStageTests(unittest.TestCase):
|
|
|
|
def test_stage(self):
|
|
|
|
stage = BlendLinearStage()
|
2023-11-20 05:18:57 +00:00
|
|
|
sources = StageResult(
|
|
|
|
images=[
|
|
|
|
Image.new("RGB", (64, 64), "black"),
|
|
|
|
]
|
|
|
|
)
|
2023-09-13 22:27:44 +00:00
|
|
|
stage_source = Image.new("RGB", (64, 64), "white")
|
2023-11-20 05:18:57 +00:00
|
|
|
result = stage.run(
|
|
|
|
None, None, None, None, sources, alpha=0.5, stage_source=stage_source
|
|
|
|
)
|
2023-09-13 22:27:44 +00:00
|
|
|
|
|
|
|
self.assertEqual(len(result), 1)
|
2023-11-20 05:18:57 +00:00
|
|
|
self.assertEqual(result.as_image()[0].getpixel((0, 0)), (127, 127, 127))
|