**基于PAI-DSW在Jupyterlab内建模地址:**https://dsw-gateway-cn-hangzhou.data.aliyun.com/dsw-14046/lab/workspaces/auto-a/tree/CV_test20221016.ipynb
打开CPU实例通常需要2-5分钟,打开GPU实例通常需要8-10分钟,请耐心等待
第一次运行,需要加载相关的库和数据集
一般不到1秒左右即可得出推理结果
import cv2
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
img_cartoon = pipeline(Tasks.image_portrait_stylization,
model='damo/cv_unet_person-image-cartoon_compound-models')
import time
StartTime = time.clock()
# 图像本地路径
img_path = 'test001.jpg'
# 图像url链接
# img_path = '/test/images/image_cartoon.png'
result = img_cartoon(img_path)
cv2.imwrite('result01.jpg', result[OutputKeys.OUTPUT_IMG])
EndTime = time.clock()
CostTime=EndTime-StartTime
print('代码运行时间:',CostTime)