CV之ModelScope:基于ModelScope框架的人脸人像数据集利用DCT-Net算法实现人像卡通化图文教程之详细攻略
官方文档:
https://www./models/damo/cv_unet_person-image-cartoon_compound-models/summary
基于ModelScope框架的人脸人像数据集利用DCT-Net算法实现人像卡通化图文教程之详细攻略
建立在线环境
基于PAI-DSW在Jupyterlab内建模地址:
https://dsw-gateway-cn-hangzhou.data.aliyun.com/dsw-14046/lab/workspaces/auto-a/tree/CV_test20221016.ipynb
打开在线Notebook—Jupyterlab
![](http://image109.360doc.com/DownloadImg/2022/10/2120/254474933_1_20221021080606852_wm.png)
![](http://image109.360doc.com/DownloadImg/2022/10/2120/254474933_2_20221021080607134_wm.png)
打开CPU实例通常需要2-5分钟,打开GPU实例通常需要8-10分钟,请耐心等待
基于PAI-DSW在Jupyterlab内建模
第一次运行,需要加载相关的库和数据集
![](http://image109.360doc.com/DownloadImg/2022/10/2120/254474933_3_20221021080607664_wm.png)
![](http://image109.360doc.com/DownloadImg/2022/10/2120/254474933_4_2022102108060839_wm.png)
![](http://image109.360doc.com/DownloadImg/2022/10/2120/254474933_5_2022102108060955_wm.png)
输出结果
一般不到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 = 'https://modelscope.oss-cn-beijing./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)