Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9251871master
| @@ -25,7 +25,7 @@ pip install --upgrade tensorflow | |||||
| ### pip安装 | ### pip安装 | ||||
| 执行如下命令: | 执行如下命令: | ||||
| ```shell | ```shell | ||||
| pip install model_scope[all] -f https://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/release/maas/repo.html | |||||
| pip install model_scope[all] -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/0.2/repo.html | |||||
| ``` | ``` | ||||
| ### 使用源码安装 | ### 使用源码安装 | ||||
| 适合本地开发调试使用,修改源码后可以直接执行 | 适合本地开发调试使用,修改源码后可以直接执行 | ||||
| @@ -54,9 +54,8 @@ print(word_seg(input)) | |||||
| 下面以一个图像任务:人像抠图('image-matting')为例,进一步说明pipeline的用法 | 下面以一个图像任务:人像抠图('image-matting')为例,进一步说明pipeline的用法 | ||||
| ```python | ```python | ||||
| import cv2 | import cv2 | ||||
| import os.path as osp | |||||
| from modelscope.pipelines import pipeline | from modelscope.pipelines import pipeline | ||||
| img_matting = pipeline('image-matting') | img_matting = pipeline('image-matting') | ||||
| result = img_matting('http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/data/test/maas/image_matting/test.png') | |||||
| result = img_matting('https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/image_matting.png') | |||||
| cv2.imwrite('result.png', result['output_png']) | cv2.imwrite('result.png', result['output_png']) | ||||
| ``` | ``` | ||||
| @@ -26,8 +26,7 @@ class FileTest(unittest.TestCase): | |||||
| def test_http_storage(self): | def test_http_storage(self): | ||||
| storage = HTTPStorage() | storage = HTTPStorage() | ||||
| url = 'http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com' \ | |||||
| '/data/test/data.txt' | |||||
| url = 'https://modelscope.oss-cn-beijing.aliyuncs.com/test/texts/data.txt' | |||||
| content = 'this is test data' | content = 'this is test data' | ||||
| self.assertEqual(content.encode('utf8'), storage.read(url)) | self.assertEqual(content.encode('utf8'), storage.read(url)) | ||||
| self.assertEqual(content, storage.read_text(url)) | self.assertEqual(content, storage.read_text(url)) | ||||
| @@ -43,8 +42,7 @@ class FileTest(unittest.TestCase): | |||||
| storage.read(url + 'df') | storage.read(url + 'df') | ||||
| def test_file(self): | def test_file(self): | ||||
| url = 'http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com'\ | |||||
| '/data/test/data.txt' | |||||
| url = 'https://modelscope.oss-cn-beijing.aliyuncs.com/test/texts/data.txt' | |||||
| content = 'this is test data' | content = 'this is test data' | ||||
| self.assertEqual(content.encode('utf8'), File.read(url)) | self.assertEqual(content.encode('utf8'), File.read(url)) | ||||
| @@ -12,7 +12,7 @@ class MultiModalFeatureTest(unittest.TestCase): | |||||
| animal_recog = pipeline( | animal_recog = pipeline( | ||||
| Tasks.image_classification, | Tasks.image_classification, | ||||
| model='damo/cv_resnest101_animal_recognition') | model='damo/cv_resnest101_animal_recognition') | ||||
| result = animal_recog('data/test/images/image1.jpg') | |||||
| result = animal_recog('data/test/images/dogs.jpg') | |||||
| print(result) | print(result) | ||||
| @@ -81,7 +81,7 @@ class CustomPipelineTest(unittest.TestCase): | |||||
| pipe2 = pipeline(dummy_task) | pipe2 = pipeline(dummy_task) | ||||
| self.assertTrue(type(pipe) is type(pipe2)) | self.assertTrue(type(pipe) is type(pipe2)) | ||||
| img_url = 'data/test/images/image1.jpg' | |||||
| img_url = 'data/test/images/dogs.jpg' | |||||
| output = pipe(img_url) | output = pipe(img_url) | ||||
| self.assertEqual(output['filename'], img_url) | self.assertEqual(output['filename'], img_url) | ||||
| self.assertEqual(output[OutputKeys.OUTPUT_IMG].shape, (318, 512, 3)) | self.assertEqual(output[OutputKeys.OUTPUT_IMG].shape, (318, 512, 3)) | ||||
| @@ -16,9 +16,7 @@ class ImageCartoonTest(unittest.TestCase): | |||||
| def setUp(self) -> None: | def setUp(self) -> None: | ||||
| self.model_id = 'damo/cv_unet_person-image-cartoon_compound-models' | self.model_id = 'damo/cv_unet_person-image-cartoon_compound-models' | ||||
| self.test_image = \ | |||||
| 'http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com' \ | |||||
| '/data/test/maas/image_carton/test.png' | |||||
| self.test_image = 'https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/image_cartoon.png' | |||||
| def pipeline_inference(self, pipeline: Pipeline, input_location: str): | def pipeline_inference(self, pipeline: Pipeline, input_location: str): | ||||
| result = pipeline(input_location) | result = pipeline(input_location) | ||||