Files
modelscope/tests/pipelines/test_image_debanding.py
wenqi.oywq da417655f2 新增deeplpf和debanding模型
1. 新增加 image_debanding 模型
2. 新增加 deeplpf_image_color_enhance 模型

Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/11579722
2023-02-09 13:08:50 +00:00

46 lines
1.7 KiB
Python

# Copyright (c) Alibaba, Inc. and its affiliates.
import os.path as osp
import unittest
import cv2
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.pipelines.base import Pipeline
from modelscope.utils.constant import Tasks
from modelscope.utils.demo_utils import DemoCompatibilityCheck
from modelscope.utils.test_utils import test_level
class ImageColorEnhanceTest(unittest.TestCase, DemoCompatibilityCheck):
def setUp(self) -> None:
self.model_id = 'damo/cv_rrdb_image-debanding'
self.task = Tasks.image_debanding
def pipeline_inference(self, pipeline: Pipeline, input_location: str):
result = pipeline(input_location)
if result is not None:
cv2.imwrite('result.png', result[OutputKeys.OUTPUT_IMG])
print(f'Output written to {osp.abspath("result.png")}')
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
def test_run_modelhub(self):
img_debanding = pipeline(Tasks.image_debanding, model=self.model_id)
self.pipeline_inference(img_debanding,
'data/test/images/image_debanding.png')
@unittest.skipUnless(test_level() >= 2, 'skip test in current test level')
def test_run_modelhub_default_model(self):
img_debanding = pipeline(Tasks.image_debanding)
self.pipeline_inference(img_debanding,
'data/test/images/image_debanding.png')
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
def test_demo_compatibility(self):
self.compatibility_check()
if __name__ == '__main__':
unittest.main()