我也遇到下载失败问题。。。snapshot_download和library下载都是小文件可以下载,大文件下载30多秒就会“远程主机强迫关闭了一个现有的连接”。。哎。。
下载模型用snapshot_download比较方便,您试一下下面的代码,我这能跑。
import cv2
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.hub.snapshot_download import snapshot_download
model_dir = snapshot_download('damo/cv_unet-image-face-fusion_damo')
image_face_fusion = pipeline(Tasks.image_face_fusion,
model=model_dir)
template_path = 'https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/facefusion_template.jpg'
user_path = 'https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/facefusion_user.jpg'
result = image_face_fusion(dict(template=template_path, user=user_path))
cv2.imwrite('result.png', result[OutputKeys.OUTPUT_IMG])
print(model_dir)
print('finished!'),此回答整理自钉群“魔搭ModelScope开发者联盟群 ①”