|
|
|
@@ -14,7 +14,7 @@ from modelscope.utils.constant import ModelFile, Tasks |
|
|
|
from modelscope.utils.test_utils import test_level |
|
|
|
|
|
|
|
|
|
|
|
class StyleTransferTest(unittest.TestCase): |
|
|
|
class ImageStyleTransferTest(unittest.TestCase): |
|
|
|
|
|
|
|
def setUp(self) -> None: |
|
|
|
self.model_id = 'damo/cv_aams_style-transfer_damo' |
|
|
|
@@ -23,18 +23,20 @@ class StyleTransferTest(unittest.TestCase): |
|
|
|
def test_run_by_direct_model_download(self): |
|
|
|
snapshot_path = snapshot_download(self.model_id) |
|
|
|
print('snapshot_path: {}'.format(snapshot_path)) |
|
|
|
style_transfer = pipeline(Tasks.style_transfer, model=snapshot_path) |
|
|
|
image_style_transfer = pipeline( |
|
|
|
Tasks.image_style_transfer, model=snapshot_path) |
|
|
|
|
|
|
|
result = style_transfer( |
|
|
|
result = image_style_transfer( |
|
|
|
'data/test/images/style_transfer_content.jpg', |
|
|
|
style='data/test/images/style_transfer_style.jpg') |
|
|
|
cv2.imwrite('result_styletransfer1.png', result[OutputKeys.OUTPUT_IMG]) |
|
|
|
|
|
|
|
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level') |
|
|
|
def test_run_modelhub(self): |
|
|
|
style_transfer = pipeline(Tasks.style_transfer, model=self.model_id) |
|
|
|
image_style_transfer = pipeline( |
|
|
|
Tasks.image_style_transfer, model=self.model_id) |
|
|
|
|
|
|
|
result = style_transfer( |
|
|
|
result = image_style_transfer( |
|
|
|
'data/test/images/style_transfer_content.jpg', |
|
|
|
style='data/test/images/style_transfer_style.jpg') |
|
|
|
cv2.imwrite('result_styletransfer2.png', result[OutputKeys.OUTPUT_IMG]) |
|
|
|
@@ -42,9 +44,9 @@ class StyleTransferTest(unittest.TestCase): |
|
|
|
|
|
|
|
@unittest.skipUnless(test_level() >= 2, 'skip test in current test level') |
|
|
|
def test_run_modelhub_default_model(self): |
|
|
|
style_transfer = pipeline(Tasks.style_transfer) |
|
|
|
image_style_transfer = pipeline(Tasks.image_style_transfer) |
|
|
|
|
|
|
|
result = style_transfer( |
|
|
|
result = image_style_transfer( |
|
|
|
'data/test/images/style_transfer_content.jpg', |
|
|
|
style='data/test/images/style_transfer_style.jpg') |
|
|
|
cv2.imwrite('result_styletransfer3.png', result[OutputKeys.OUTPUT_IMG]) |