{"id":13935627,"url":"https://github.com/wonjongg/StyleCariGAN","last_synced_at":"2025-07-19T20:33:36.033Z","repository":{"id":42160977,"uuid":"363023547","full_name":"wonjongg/StyleCariGAN","owner":"wonjongg","description":"[SIGGRAPH 2021] Official implementation of \"StyleCariGAN: Caricature Generation via StyleGAN Feature Map Modulation\"","archived":false,"fork":false,"pushed_at":"2023-05-27T03:54:18.000Z","size":16113,"stargazers_count":292,"open_issues_count":0,"forks_count":54,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-08-08T23:21:23.097Z","etag":null,"topics":["deep-learning","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wonjongg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-30T04:14:30.000Z","updated_at":"2024-07-28T17:43:19.000Z","dependencies_parsed_at":"2022-09-10T11:01:28.293Z","dependency_job_id":null,"html_url":"https://github.com/wonjongg/StyleCariGAN","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonjongg%2FStyleCariGAN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonjongg%2FStyleCariGAN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonjongg%2FStyleCariGAN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonjongg%2FStyleCariGAN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wonjongg","download_url":"https://codeload.github.com/wonjongg/StyleCariGAN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226677160,"owners_count":17666013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","pytorch"],"created_at":"2024-08-07T23:01:56.550Z","updated_at":"2024-11-27T03:30:58.194Z","avatar_url":"https://github.com/wonjongg.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# StyleCariGAN: Caricature Generation via StyleGAN Feature Map Modulation\r\n![License CC BY_NC](https://img.shields.io/badge/license-GNU_AGPv3-blue.svg?style=plastic) \u003ca href=\"https://replicate.ai/wonjongg/stylecarigan\"\u003e\u003cimg src=\"https://img.shields.io/static/v1?label=Replicate\u0026message=Run it on Replicate\u0026color=blue\" height=18\u003e\u003c/a\u003e\r\n\r\n[![teaser](./assets/teaser.png)](https://youtu.be/kpHbGOlI-BU)\r\n\r\n📝 This repository contains the official PyTorch implementation of the following paper:\r\n\r\n\u003e **[StyleCariGAN: Caricature Generation via StyleGAN Feature Map Modulation](https://arxiv.org/abs/2107.04331)**\u003cbr\u003e\r\n\u003e Wonjong Jang, Gwangjin Ju, Yucheol Jung, Jiaolong Yang, Xin Tong, Seungyong Lee, SIGGRAPH 2021\r\n\r\n🚀 \u003e\u003e [Project page](https://wonjongg.github.io/StyleCariGAN)  \r\n🚀 \u003e\u003e [Fast-forward video](https://youtu.be/kpHbGOlI-BU)\r\n\r\n## Overview\r\n\u003cdiv align=\"center\"\u003e\r\n  \r\n![method](./assets/method.gif)\r\n\r\n\u003c/div\u003e\r\n\r\n\u003cdetails\u003e\r\n\u003csummary\u003e\u003cb\u003eExplanation\u003c/b\u003e\u003c/summary\u003e\r\n\u003cdiv markdown=\"1\"\u003e\r\nThe key component of our method is \u003cb\u003eshape exaggeration blocks\u003c/b\u003e that are used for modulating coarse layer feature maps of StyleGAN to produce desirable caricature shape exaggerations.  We first build a layer-mixed StyleGAN for photo-to-caricature style conversion by swapping fine layers of the StyleGAN for photos to the corresponding layers of the StyleGAN trained to generate caricatures. Given an input photo, the layer-mixed model produces detailed color stylization for a caricature but without shape exaggerations. We then append shape exaggeration blocks to the coarse layers of the layer-mixed model and train the blocks to create shape exaggerations while preserving the characteristic appearances of the input.\r\n\u003c/div\u003e\r\n\u003c/details\u003e\r\n\r\n## Requirements\r\n✔️ PyTorch 1.3.1  \r\n✔️ torchvision 0.4.2  \r\n✔️ CUDA 10.1/10.2  \r\n✔️ dlib 19.22.0  \r\n✔️ requests 2.23.0  \r\n✔️ tqdm 4.46.2\r\n\r\n⚠️ If you are using Anaconda environment and get errors regarding compiler version mismatch, check issue [#1](/../../issues/1).\r\n\r\n## Usage\r\n\r\nFirst download pre-trained model weights:\r\n\r\n\u003e bash ./download.sh\r\n\r\n\r\n### Train\r\n\r\n\u003e python -m torch.distributed.launch --nproc_per_node=N_GPU train.py --name EXPERIMENT_NAME --freeze_D\r\n\r\n### Test\r\n\r\n\r\nTest on user's input images:\r\n\r\n\u003e python test.py --ckpt CHECKPOINT_PATH --input_dir INPUT_IMAGE_PATH --output_dir OUTPUT_CARICATURE_PATH --invert_images\r\n\r\nWe provide some sample images. Test on sample images:\r\n\r\n\u003e python test.py --ckpt CHECKPOINT_PATH --input_dir examples/samples --output_dir examples/results --invert_images\r\n\r\nIt inverts latent codes from input photos and generates caricatures from latent codes.\r\n\r\n## Examples\r\n\u003cdiv align=\"center\"\u003e\r\n  \r\n|Input image|Output caricature|\r\n|:-:|:-:|\r\n|![img1](./examples/samples/2.png)|![cari1](./examples/results/2/23.png)|\r\n|![img2](./examples/samples/3.jpg)|![cari2](./examples/results/3/19.png)|\r\n|![img3](./examples/samples/4.png)|![cari3](./examples/results/4/15.png)|\r\n|![img4](./examples/samples/5.png)|![cari4](./examples/results/5/52.png)|\r\n\r\n\u003c/div\u003e\r\n\r\n## Citation\r\nIf you find this code useful, please consider citing:\r\n```\r\n@article{Jang2021StyleCari,\r\n  author    = {Wonjong Jang and Gwangjin Ju and Yucheol Jung and Jiaolong Yang and Xin Tong and Seungyong Lee},\r\n  title     = {StyleCariGAN: Caricature Generation via StyleGAN Feature Map Modulation},\r\n  booktitle = {ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH)},\r\n  publisher = {ACM},\r\n  volume = {40},\r\n  number = {4},\r\n  year = {2021}\r\n}\r\n```\r\n\r\n## Download pre-trained models\r\n\r\n🏷️ [StyleCariGAN](https://drive.google.com/file/d/18UKYtQ46M0inNrgnBzfYub38-uzQHp7Y/view?usp=share_link)  \r\n🏷️ [Photo-StyleGAN (generator_ffhq.pt)](https://drive.google.com/file/d/1rI41-df-kXIcukpRCBEOzVHf374b9AAB/view?usp=share_link)  \r\n🏷️ [Caricature-StyleGAN (generator_cari.pt)](https://drive.google.com/file/d/1H8LUmTStiYB-L5ofbAZwQ6D7WP1By73_/view?usp=share_link)  \r\n🏷️ [Photo-Attribute-Classifier (photo_resnet.pth)](https://drive.google.com/file/d/1DbRDo2ifoLFbJXLAdO7-pJdJkDHCxOFd/view?usp=share_link)  \r\n🏷️ [Cari-Attribute-Classifier (cari_resnet.pth)](https://drive.google.com/file/d/1-AC0BY46foSWss4kjP_F4Vt67lTsTe1j/view?usp=share_link)  \r\n\r\n\r\n\r\n\r\n## Contact\r\n📫 You can have contact with [wonjong@postech.ac.kr](mailto:wonjong@postech.ac.kr) or [ycjung@postech.ac.kr](mailto:ycjung@postech.ac.kr)\r\n\r\n## License\r\nThis software is being made available under the terms in the [LICENSE](LICENSE) file.\r\n\r\nAny exemptions to these terms require a license from the Pohang University of Science and Technology.\r\n\r\n## Credits\r\n❤️ Our code is based on [the official StyleGAN2 implementation](https://github.com/NVlabs/stylegan2) and [rosinality's StyleGAN2-pytorch code](https://github.com/rosinality/stylegan2-pytorch)  \r\n❤️ Specially thanks to [CJWBW](https://github.com/CJWBW) who ported our project to [Replicate](https://replicate.ai/wonjongg/stylecarigan).\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwonjongg%2FStyleCariGAN","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwonjongg%2FStyleCariGAN","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwonjongg%2FStyleCariGAN/lists"}