-
Notifications
You must be signed in to change notification settings - Fork 76
/
run_sdk.py
51 lines (42 loc) · 2 KB
/
run_sdk.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import cv2
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
##### DCT-Net
## anime style
img_cartoon = pipeline(Tasks.image_portrait_stylization,
model='damo/cv_unet_person-image-cartoon_compound-models')
result = img_cartoon('input.png')
cv2.imwrite('result_anime.png', result[OutputKeys.OUTPUT_IMG])
## 3d style
img_cartoon = pipeline(Tasks.image_portrait_stylization,
model='damo/cv_unet_person-image-cartoon-3d_compound-models')
result = img_cartoon('input.png')
cv2.imwrite('result_3d.png', result[OutputKeys.OUTPUT_IMG])
## handdrawn style
img_cartoon = pipeline(Tasks.image_portrait_stylization,
model='damo/cv_unet_person-image-cartoon-handdrawn_compound-models')
result = img_cartoon('input.png')
cv2.imwrite('result_handdrawn.png', result[OutputKeys.OUTPUT_IMG])
## sketch style
img_cartoon = pipeline(Tasks.image_portrait_stylization,
model='damo/cv_unet_person-image-cartoon-sketch_compound-models')
result = img_cartoon('input.png')
cv2.imwrite('result_sketch.png', result[OutputKeys.OUTPUT_IMG])
## artstyle style
img_cartoon = pipeline(Tasks.image_portrait_stylization,
model='damo/cv_unet_person-image-cartoon-artstyle_compound-models')
result = img_cartoon('input.png')
cv2.imwrite('result_artstyle.png', result[OutputKeys.OUTPUT_IMG])
#### DCT-Net + SD
## design style
img_cartoon = pipeline(Tasks.image_portrait_stylization,
model='damo/cv_unet_person-image-cartoon-sd-design_compound-models')
result = img_cartoon('input.png')
cv2.imwrite('result_sd_design.png', result[OutputKeys.OUTPUT_IMG])
## illustration style
img_cartoon = pipeline(Tasks.image_portrait_stylization,
model='damo/cv_unet_person-image-cartoon-sd-illustration_compound-models')
result = img_cartoon('input.png')
cv2.imwrite('result_sd_illustration.png', result[OutputKeys.OUTPUT_IMG])
print('finished!')