diff --git a/.DS_Store b/.DS_Store index 3649d19..e955512 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/assets/sim1.png b/assets/sim1.png new file mode 100644 index 0000000..df66212 Binary files /dev/null and b/assets/sim1.png differ diff --git a/assets/sim2.png b/assets/sim2.png new file mode 100644 index 0000000..fddf01e Binary files /dev/null and b/assets/sim2.png differ diff --git a/assets/sim3.png b/assets/sim3.png new file mode 100644 index 0000000..7b90591 Binary files /dev/null and b/assets/sim3.png differ diff --git a/assets/sim4.png b/assets/sim4.png new file mode 100644 index 0000000..b926d37 Binary files /dev/null and b/assets/sim4.png differ diff --git a/assets/sim5.png b/assets/sim5.png new file mode 100644 index 0000000..2fbcccf Binary files /dev/null and b/assets/sim5.png differ diff --git a/assets/sim_3d.png b/assets/sim_3d.png new file mode 100644 index 0000000..fea74af Binary files /dev/null and b/assets/sim_3d.png differ diff --git a/assets/sim_anime.png b/assets/sim_anime.png new file mode 100644 index 0000000..49adc1e Binary files /dev/null and b/assets/sim_anime.png differ diff --git a/assets/sim_artstyle.png b/assets/sim_artstyle.png new file mode 100644 index 0000000..7cdacdb Binary files /dev/null and b/assets/sim_artstyle.png differ diff --git a/assets/sim_design.png b/assets/sim_design.png new file mode 100644 index 0000000..2756653 Binary files /dev/null and b/assets/sim_design.png differ diff --git a/assets/sim_handdrawn.png b/assets/sim_handdrawn.png new file mode 100644 index 0000000..89a76b8 Binary files /dev/null and b/assets/sim_handdrawn.png differ diff --git a/assets/sim_illu.png b/assets/sim_illu.png new file mode 100644 index 0000000..c899686 Binary files /dev/null and b/assets/sim_illu.png differ diff --git a/assets/sim_sketch.png b/assets/sim_sketch.png new file mode 100644 index 0000000..b606913 Binary files /dev/null and b/assets/sim_sketch.png differ diff --git a/assets/demo_sin.gif b/assets/video.gif similarity index 51% rename from assets/demo_sin.gif rename to assets/video.gif index 1404f20..7ab3c18 100644 Binary files a/assets/demo_sin.gif and b/assets/video.gif differ diff --git a/celeb.txt b/celeb.txt new file mode 100755 index 0000000..ade68e3 --- /dev/null +++ b/celeb.txt @@ -0,0 +1,201 @@ +Beyoncé +Taylor Swift +Rihanna +Ariana Grande +Angelina Jolie +Jennifer Lawrence +Emma Watson +Katy Perry +Scarlett Johansson +Lady Gaga +Gal Gadot +Selena Gomez +Sandra Bullock +Ellen DeGeneres +Mila Kunis +Jennifer Aniston +Margot Robbie +Blake Lively +Miley Cyrus +Charlize Theron +Emma Stone +Sofia Vergara +Halle Berry +Zendaya +Dwayne Johnson +Lady Amelia Windsor +Brie Larson +Adele +Janelle Monae +Shakira +Priyanka Chopra +Betty White +Nina Dobrev +Meghan Markle +Lupita Nyong'o +Emilia Clarke +Kate Middleton +Zooey Deschanel +Sienna Miller +Christina Aguilera +Kate Hudson +Gina Rodriguez +Cardi B +Yara Shahidi +Michelle Obama +Kourtney Kardashian +Portia de Rossi +Kerry Washington +Jada Pinkett Smith +Lucy Liu +Victoria Beckham +Gwyneth Paltrow +Kim Kardashian +Ellen Page +Kerry Washington +Maya Rudolph +Alicia Keys +Oprah Winfrey +Tracee Ellis Ross +Jennifer Lopez +Rachel McAdams +Pink +Cameron Diaz +Lily Collins +Anne Hathaway +Tyra Banks +Ashley Tisdale +Amanda Seyfried +Jessica Alba +Demi Lovato +Keira Knightley +Bella Hadid +Kendall Jenner +Emma Roberts +Vanessa Hudgens +Sofia Richie +Hailey Bieber +Gisele Bündchen +Taylor Hill +Kiki Layne +Cate Blanchett +Kate Winslet +Gal Gadot +Salma Hayek +Julia Roberts +Mariah Carey +Scarlett Johansson +Rosie Huntington-Whitely +Marjane Satrapi +Halle Berry +Mariah Carey +Selena Gomez +Emma Watson +Jennifer Aniston +Rihanna +Blake Lively +Ariana Grande +Angelina Jolie +Lady Gaga +Taylor Swift + +Robert Downey Jr. +Tom Cruise +George Clooney +Brad Pitt +Dwayne Johnson +Leonardo DiCaprio +Will Smith +Johnny Depp +Chris Evans +Ryan Reynolds +Tom Hanks +Matt Damon +Denzel Washington +Hugh Jackman +Chris Hemsworth +Chris Pratt +Idris Elba +Daniel Craig +Samuel L. Jackson +Jeremy Renner +Chris Pine +Robert Pattinson +Sebastian Stan +Benedict Cumberbatch +Paul Rudd +Mark Wahlberg +Zac Efron +Jason Statham +Michael Fassbender +Joel Kinnaman +Keanu Reeves +Scarlett Johansson +Vin Diesel +Angelina Jolie +Emma Watson +Jennifer Lawrence +Gal Gadot +Margot Robbie +Brie Larson +Sofia Vergara +Mila Kunis +Emily Blunt +Sandra Bullock +Kate Winslet +Nicole Kidman +Charlize Theron +Anne Hathaway +Cate Blanchett +Emma Stone +Lupita Nyong'o +Jennifer Aniston +Halle Berry +Rihanna +Lady Gaga +Beyoncé +Taylor Swift +Miley Cyrus +Ariana Grande +Meghan Markle +Kate Middleton +Angelina Jolie +Jennifer Lopez +Shakira +Katy Perry +Lady Gaga +Britney Spears +Adele +Mariah Carey +Madonna +Janet Jackson +Whitney Houston +Tina Turner +Celine Dion +Barbra Streisand +Cher +Gloria Estefan +Diana Ross +Julie Andrews +Liza Minnelli +Bette Midler +Elton John +Freddie Mercury +Paul McCartney +Elvis Presley +Michael Jackson +Prince +Madonna +Mariah Carey +Janet Jackson +Whitney Houston +Tina Turner +Celine Dion +Barbra Streisand +Cher +Gloria Estefan +Diana Ross +Julie Andrews +Liza Minnelli +Bette Midler +Elton John \ No newline at end of file diff --git a/download.py b/download.py index 78c4570..d828699 100644 --- a/download.py +++ b/download.py @@ -1,4 +1,13 @@ from modelscope.hub.snapshot_download import snapshot_download +# pre-trained models in different style model_dir = snapshot_download('damo/cv_unet_person-image-cartoon_compound-models', cache_dir='.') +model_dir = snapshot_download('damo/cv_unet_person-image-cartoon-3d_compound-models', cache_dir='.') +model_dir = snapshot_download('damo/cv_unet_person-image-cartoon-handdrawn_compound-models', cache_dir='.') +model_dir = snapshot_download('damo/cv_unet_person-image-cartoon-sketch_compound-models', cache_dir='.') +model_dir = snapshot_download('damo/cv_unet_person-image-cartoon-artstyle_compound-models', cache_dir='.') + +# pre-trained models trained with DCT-Net + Stable-Diffusion +model_dir = snapshot_download('damo/cv_unet_person-image-cartoon-sd-design_compound-models', revision='v1.0.0', cache_dir='.') +model_dir = snapshot_download('damo/cv_unet_person-image-cartoon-sd-illustration_compound-models', revision='v1.0.0', cache_dir='.') diff --git a/generate_data.py b/generate_data.py new file mode 100644 index 0000000..af86a41 --- /dev/null +++ b/generate_data.py @@ -0,0 +1,59 @@ +from modelscope.pipelines import pipeline +from modelscope.utils.constant import Tasks +import torch +import os, cv2 +import argparse + +def load_cele_txt(celeb_file='celeb.txt'): + celeb = open(celeb_file, 'r') + lines = celeb.readlines() + name_list = [] + for line in lines: + name = line.strip('\n') + if name != '': + name_list.append(name) + return name_list + + +def main(args): + style = args.style + repeat_num = 5 + + model_id = 'damo/cv_cartoon_stable_diffusion_' + style + pipe = pipeline(Tasks.text_to_image_synthesis, model=model_id, + model_revision='v1.0.0', torch_dtype=torch.float16) + from diffusers.schedulers import EulerAncestralDiscreteScheduler + pipe.pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.pipeline.scheduler.config) + print('model init finished!') + + + save_dir = 'res_style_%s/syn_celeb' % (style) + if not os.path.exists(save_dir): + os.makedirs(save_dir) + + name_list = load_cele_txt('celeb.txt') + person_num = len(name_list) + for i in range(person_num): + name = name_list[i] + print('process %s' % name) + + if style == "clipart": + prompt = 'archer style, a portrait painting of %s' % (name) + else: + prompt = 'sks style, a painting of a %s, no text' % (name) + + images = pipe({'text': prompt, 'num_images_per_prompt': repeat_num})['output_imgs'] + idx = 0 + for image in images: + outpath = os.path.join(save_dir, '%s_%d.png' % (name, idx)) + cv2.imwrite(outpath, image) + idx += 1 + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('--style', type=str, default='clipart') + + args = parser.parse_args() + main(args) + diff --git a/run_sdk.py b/run_sdk.py index 9180411..b42cb24 100644 --- a/run_sdk.py +++ b/run_sdk.py @@ -3,9 +3,49 @@ 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]) + -cv2.imwrite('result.png', result[OutputKeys.OUTPUT_IMG]) print('finished!')