mirror of https://github.com/menyifang/DCT-Net
update multi-style models
parent
da7507498a
commit
6d5917c982
Binary file not shown.
After Width: | Height: | Size: 1.8 MiB |
Binary file not shown.
Before Width: | Height: | Size: 942 KiB After Width: | Height: | Size: 1.1 MiB |
@ -0,0 +1,35 @@
|
||||
from modelscope.hub.snapshot_download import snapshot_download
|
||||
import argparse
|
||||
|
||||
|
||||
|
||||
def process(args):
|
||||
style = args.style
|
||||
print('download %s model'%style)
|
||||
if style == "anime":
|
||||
model_dir = snapshot_download('damo/cv_unet_person-image-cartoon_compound-models', cache_dir='.')
|
||||
|
||||
elif style == "3d":
|
||||
model_dir = snapshot_download('damo/cv_unet_person-image-cartoon-3d_compound-models', cache_dir='.')
|
||||
|
||||
elif style == "handdrawn":
|
||||
model_dir = snapshot_download('damo/cv_unet_person-image-cartoon-handdrawn_compound-models', cache_dir='.')
|
||||
|
||||
elif style == "sketch":
|
||||
model_dir = snapshot_download('damo/cv_unet_person-image-cartoon-sketch_compound-models', cache_dir='.')
|
||||
|
||||
elif style == "artstyle":
|
||||
model_dir = snapshot_download('damo/cv_unet_person-image-cartoon-artstyle_compound-models', cache_dir='.')
|
||||
|
||||
else:
|
||||
print('no such style %s'% style)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--style', type=str, default='anime')
|
||||
args = parser.parse_args()
|
||||
|
||||
process(args)
|
@ -0,0 +1,49 @@
|
||||
import sys
|
||||
sys.path.append('.')
|
||||
|
||||
import cv2
|
||||
from source.cartoonize import Cartoonizer
|
||||
import os
|
||||
import argparse
|
||||
|
||||
|
||||
def process(args):
|
||||
|
||||
style = args.style
|
||||
if style == "anime":
|
||||
algo = Cartoonizer(dataroot='damo/cv_unet_person-image-cartoon_compound-models')
|
||||
|
||||
elif style == "3d":
|
||||
algo = Cartoonizer(dataroot='damo/cv_unet_person-image-cartoon-3d_compound-models')
|
||||
|
||||
elif style == "handdrawn":
|
||||
algo = Cartoonizer(dataroot='damo/cv_unet_person-image-cartoon-handdrawn_compound-models')
|
||||
|
||||
elif style == "sketch":
|
||||
algo = Cartoonizer(dataroot='damo/cv_unet_person-image-cartoon-sketch_compound-models')
|
||||
|
||||
elif style == "artstyle":
|
||||
algo = Cartoonizer(dataroot='damo/cv_unet_person-image-cartoon-artstyle_compound-models')
|
||||
|
||||
else:
|
||||
print('no such style %s' % style)
|
||||
return 0
|
||||
|
||||
img = cv2.imread('input.png')[..., ::-1]
|
||||
result = algo.cartoonize(img)
|
||||
cv2.imwrite('result1_%s.png'%style, result)
|
||||
|
||||
print('finished!')
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--style', type=str, default='anime')
|
||||
args = parser.parse_args()
|
||||
|
||||
process(args)
|
||||
|
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
import cv2, argparse
|
||||
from modelscope.outputs import OutputKeys
|
||||
from modelscope.pipelines import pipeline
|
||||
from modelscope.utils.constant import Tasks
|
||||
|
||||
def process(args):
|
||||
style = args.style
|
||||
print('choose style %s'%style)
|
||||
if style == "anime":
|
||||
img_cartoon = pipeline(Tasks.image_portrait_stylization,
|
||||
model='damo/cv_unet_person-image-cartoon_compound-models')
|
||||
elif style == "3d":
|
||||
img_cartoon = pipeline(Tasks.image_portrait_stylization,
|
||||
model='damo/cv_unet_person-image-cartoon-3d_compound-models')
|
||||
elif style == "handdrawn":
|
||||
img_cartoon = pipeline(Tasks.image_portrait_stylization,
|
||||
model='damo/cv_unet_person-image-cartoon-handdrawn_compound-models')
|
||||
elif style == "sketch":
|
||||
img_cartoon = pipeline(Tasks.image_portrait_stylization,
|
||||
model='damo/cv_unet_person-image-cartoon-sketch_compound-models')
|
||||
elif style == "artstyle":
|
||||
img_cartoon = pipeline(Tasks.image_portrait_stylization,
|
||||
model='damo/cv_unet_person-image-cartoon-artstyle_compound-models')
|
||||
else:
|
||||
print('no such style %s'% style)
|
||||
return 0
|
||||
|
||||
|
||||
result = img_cartoon('input.png')
|
||||
|
||||
cv2.imwrite('result_%s.png'%style, result[OutputKeys.OUTPUT_IMG])
|
||||
print('finished!')
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--style', type=str, default='anime')
|
||||
args = parser.parse_args()
|
||||
|
||||
process(args)
|
Loading…
Reference in New Issue