{"id":13701667,"url":"https://github.com/williamyang1991/DualStyleGAN","last_synced_at":"2025-05-04T21:31:26.190Z","repository":{"id":37381097,"uuid":"469282325","full_name":"williamyang1991/DualStyleGAN","owner":"williamyang1991","description":"[CVPR 2022] Pastiche Master: Exemplar-Based High-Resolution Portrait Style Transfer","archived":false,"fork":false,"pushed_at":"2023-03-06T09:30:54.000Z","size":26840,"stargazers_count":1663,"open_issues_count":29,"forks_count":257,"subscribers_count":28,"default_branch":"main","last_synced_at":"2025-04-08T09:06:01.061Z","etag":null,"topics":["caricatures","cvpr2022","face","style-transfer","stylegan-image-manipulation","stylegan2","toonify"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/williamyang1991.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-03-13T05:47:51.000Z","updated_at":"2025-04-03T09:36:08.000Z","dependencies_parsed_at":"2024-01-15T03:42:50.989Z","dependency_job_id":null,"html_url":"https://github.com/williamyang1991/DualStyleGAN","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/williamyang1991%2FDualStyleGAN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamyang1991%2FDualStyleGAN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamyang1991%2FDualStyleGAN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamyang1991%2FDualStyleGAN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/williamyang1991","download_url":"https://codeload.github.com/williamyang1991/DualStyleGAN/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252404031,"owners_count":21742482,"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":["caricatures","cvpr2022","face","style-transfer","stylegan-image-manipulation","stylegan2","toonify"],"created_at":"2024-08-02T20:01:54.062Z","updated_at":"2025-05-04T21:31:21.180Z","avatar_url":"https://github.com/williamyang1991.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook","Unsupervised Image Transaltion"],"sub_categories":["Multi-domain"],"readme":"# DualStyleGAN - Official PyTorch Implementation\n\n\u003cimg src=\"./doc_images/overview.jpg\" width=\"96%\" height=\"96%\"\u003e\n\nThis repository provides the official PyTorch implementation for the following paper:\n\n**Pastiche Master: Exemplar-Based High-Resolution Portrait Style Transfer**\u003cbr\u003e\n[Shuai Yang](https://williamyang1991.github.io/), [Liming Jiang](https://liming-jiang.com/), [Ziwei Liu](https://liuziwei7.github.io/) and [Chen Change Loy](https://www.mmlab-ntu.com/person/ccloy/)\u003cbr\u003e\nIn CVPR 2022.\u003cbr\u003e\n[**Project Page**](https://www.mmlab-ntu.com/project/dualstylegan/) | [**Paper**](https://arxiv.org/abs/2203.13248) | [**Supplementary Video**](https://www.youtube.com/watch?v=scZTu77jixI)\n\u003e **Abstract:** *Recent studies on StyleGAN show high performance on artistic portrait generation by transfer learning with limited data. In this paper, we explore more challenging exemplar-based high-resolution portrait style transfer by introducing a novel \u003cb\u003eDualStyleGAN\u003c/b\u003e with flexible control of dual styles of the original face domain and the extended artistic portrait domain. Different from StyleGAN, DualStyleGAN provides a natural way of style transfer by characterizing the content and style of a portrait with an \u003cb\u003eintrinsic style path\u003c/b\u003e and a new \u003cb\u003eextrinsic style path\u003c/b\u003e, respectively. The delicately designed extrinsic style path enables our model to modulate both the color and complex structural styles hierarchically to precisely pastiche the style example. Furthermore, a novel progressive fine-tuning scheme is introduced to smoothly transform the generative space of the model to the target domain, even with the above modifications on the network architecture. Experiments demonstrate the superiority of DualStyleGAN over state-of-the-art methods in high-quality portrait style transfer and flexible style control.*\n\n**Features**:\u003cbr\u003e \n**High-Resolution** (1024) | **Training Data-Efficient** (~200 Images) | **Exemplar-Based Color and Structure Transfer**\n\n## Updates\n\n- [02/2023] Add `--wplus` in style_transfer.py to use original w+ pSp encoder rather than z+.\n- [09/2022] Pre-trained models in three new [styles](#combine-dualstylegan-with-state-of-the-art-diffusion-model) (feat. StableDiffusion) are released. \n- [07/2022] Source code license is updated.\n- [03/2022] Paper and supplementary video are released.\n- [03/2022] Web demo is created.\n- [03/2022] Code is released.\n- [03/2022] This website is created.\n\n\n## Web Demo\n\nIntegrated into [Huggingface Spaces 🤗](https://huggingface.co/spaces) using [Gradio](https://github.com/gradio-app/gradio). Try out the Web Demo: [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/hysts/DualStyleGAN) or [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/Gradio-Blocks/DualStyleGAN)\n\n\n\n\n## Installation\n**Clone this repo:**\n```bash\ngit clone https://github.com/williamyang1991/DualStyleGAN.git\ncd DualStyleGAN\n```\n**Dependencies:**\n\nAll dependencies for defining the environment are provided in `environment/dualstylegan_env.yaml`.\nWe recommend running this repository using [Anaconda](https://docs.anaconda.com/anaconda/install/):\n```bash\nconda env create -f ./environment/dualstylegan_env.yaml\n```\nWe use CUDA 10.1 so it will install PyTorch 1.7.1 (corresponding to [Line 22](https://github.com/williamyang1991/DualStyleGAN/blob/main/environment/dualstylegan_env.yaml#L22), [Line 25](https://github.com/williamyang1991/DualStyleGAN/blob/main/environment/dualstylegan_env.yaml#L25), [Line 26](https://github.com/williamyang1991/DualStyleGAN/blob/main/environment/dualstylegan_env.yaml#L26) of `dualstylegan_env.yaml`). Please install PyTorch that matches your own CUDA version following [https://pytorch.org/](https://pytorch.org/).\n\n☞ Install on Windows: [here](https://github.com/williamyang1991/VToonify/issues/50#issuecomment-1443061101) and [here](https://github.com/williamyang1991/VToonify/issues/38#issuecomment-1442146800)\n\n## (1) Dataset Preparation\n\nCartoon, Caricature and Anime datasets can be downloaded from their official pages.\nWe also provide the script to build new datasets.\n\n| Dataset | Description |\n| :--- | :--- |\n| [Cartoon](https://mega.nz/file/HslSXS4a#7UBanJTjJqUl_2Z-JmAsreQYiJUKC-8UlZDR0rUsarw) | 317 cartoon face images from [Toonify](https://github.com/justinpinkney/toonify). |\n| Caricature | 199 images from [WebCaricature](https://cs.nju.edu.cn/rl/WebCaricature.htm). Please refer to [dataset preparation](./data_preparation/readme.md#caricature-dataset) for more details. |\n| Anime | 174 images from [Danbooru Portraits](https://www.gwern.net/Crops#danbooru2019-portraits). Please refer to  [dataset preparation](./data_preparation/readme.md#anime-dataset) for more details. |\n| [Fantasy](https://drive.google.com/drive/folders/1YjTuuy43jH4lRZU3tA6ZuJjNSs9a5h8n?usp=sharing) | 137 fantasy face images generated by [StableDiffusion](https://github.com/lowfuel/progrock-stable). |\n| [Illustration](https://drive.google.com/drive/folders/1eQTzlX13kUzWKLlAQjaTXQmR7ARpXdIM?usp=sharing) | 156 illustration face images generated by [StableDiffusion](https://github.com/lowfuel/progrock-stable). |\n| [Impasto](https://drive.google.com/drive/folders/1VcaMdaqHmJ4BDVK4TxNpumx3C51_2XP_?usp=sharing) | 120 impasto face images generated by [StableDiffusion](https://github.com/lowfuel/progrock-stable). |\n| Other styles | Please refer to  [dataset preparation](./data_preparation/readme.md#build-your-own-dataset) for the way of building new datasets. |\n\n\u003cbr/\u003e\n\n## (2) Inference for Style Transfer and Artistic Portrait Generation\n\n### Inference Notebook \n\u003ca href=\"http://colab.research.google.com/github/williamyang1991/DualStyleGAN/blob/master/notebooks/inference_playground.ipynb\"\u003e\u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" height=22.5\u003e\u003c/a\u003e  \nTo help users get started, we provide a Jupyter notebook found in `./notebooks/inference_playground.ipynb` that allows one to visualize the performance of DualStyleGAN.\nThe notebook will download the necessary pretrained models and run inference on the images found in `./data/`.\n\nIf no GPU is available, you may refer to [Inference on CPU](./model/stylegan/op_cpu#readme), and set `device = 'cpu'` in the notebook.\n\n### Pretrained Models\n\nPretrained models can be downloaded from [Google Drive](https://drive.google.com/drive/folders/1GZQ6Gs5AzJq9lUL-ldIQexi0JYPKNy8b?usp=sharing) or [Baidu Cloud](https://pan.baidu.com/s/1sOpPszHfHSgFsgw47S6aAA ) (access code: cvpr):\n\n| Model | Description |\n| :--- | :--- |\n| [encoder](https://drive.google.com/file/d/1NgI4mPkboYvYw3MWcdUaQhkr0OWgs9ej/view?usp=sharing) | Pixel2style2pixel encoder that embeds FFHQ images into StyleGAN2 Z+ latent code |\n| [encoder_wplus](https://drive.google.com/file/d/1IVMWKfF8Yp41tsoLLZ8edwjVg_tkjmqQ/view?usp=share_link) | Original Pixel2style2pixel encoder that embeds FFHQ images into StyleGAN2 W+ latent code |\n| [cartoon](https://drive.google.com/drive/folders/1xPo8PcbMXzcUyvwe5liJrfbA5yx4OF1j?usp=sharing) | DualStyleGAN and sampling models trained on Cartoon dataset, 317 (refined) extrinsic style codes |\n| [caricature](https://drive.google.com/drive/folders/1BwLXWkSyWDApblBPvaHKsRCTqnhiHxUZ?usp=sharing) | DualStyleGAN and sampling models trained on Caricature dataset, 199 (refined) extrinsic style codes |\n| [anime](https://drive.google.com/drive/folders/1YvFj33Bfum4YuBeqNNCYLfiBrD4tpzg7?usp=sharing) | DualStyleGAN and sampling models trained on Anime dataset, 174 (refined) extrinsic style codes |\n| [arcane](https://drive.google.com/drive/folders/1-MYwaEQthhAJ_ScWVb0LOQiVkKeSzpBm?usp=sharing) | DualStyleGAN and sampling models trained on Arcane dataset, 100 extrinsic style codes |\n| [comic](https://drive.google.com/drive/folders/1qC2onFGs2R-XCXRQTP_yyNbY1fT0BdZG?usp=sharing) | DualStyleGAN and sampling models trained on Comic dataset, 101 extrinsic style codes |\n| [pixar](https://drive.google.com/drive/folders/1ve4P8Yb4EZ9g_sRy_RCw3N74p46tNpeW?usp=sharing) | DualStyleGAN and sampling models trained on Pixar dataset, 122 extrinsic style codes |\n| [slamdunk](https://drive.google.com/drive/folders/1X345yn_YbMEHBcj7K91O-oQZ2YjVpAcI?usp=sharing) | DualStyleGAN and sampling models trained on Slamdunk dataset, 120 extrinsic style codes |\n| [fantasy](https://drive.google.com/drive/folders/1JmimgKR_Xo-lR8n35e_V9wEicSUaJqMz?usp=sharing) | DualStyleGAN models trained on Fantasy dataset, 137 extrinsic style codes |\n| [illustration](https://drive.google.com/drive/folders/1ESQBW5rmXqWss3yTjIUOr8Di7R_er-o8?usp=sharing) | DualStyleGAN models trained on Illustration dataset, 156 extrinsic style codes |\n| [impasto](https://drive.google.com/drive/folders/1d0Lb-B7ozphXLywRjVLXQI0PTC5PESfn?usp=sharing) | DualStyleGAN models trained on Impasto dataset, 120 extrinsic style codes |\n\nThe saved checkpoints are under the following folder structure:\n```\ncheckpoint\n|--encoder.pt                     % Pixel2style2pixel model\n|--encoder_wplus.pt               % Pixel2style2pixel model (optional)\n|--cartoon\n    |--generator.pt               % DualStyleGAN model\n    |--sampler.pt                 % The extrinsic style code sampling model\n    |--exstyle_code.npy           % extrinsic style codes of Cartoon dataset\n    |--refined_exstyle_code.npy   % refined extrinsic style codes of Cartoon dataset\n|--caricature\n    % the same files as in Cartoon\n...\n```\n\n### Exemplar-Based Style Transfer\nTransfer the style of a default Cartoon image onto a default face:\n```python\npython style_transfer.py \n```\nThe result `cartoon_transfer_53_081680.jpg` is saved in the folder `.\\output\\`,\nwhere `53` is the id of the style image in the Cartoon dataset, `081680` is the name of the content face image.\nAn corresponding overview image `cartoon_transfer_53_081680_overview.jpg` is additionally saved to illustrate the input content image, the encoded content image, the style image (* the style image will be shown only if it is in your folder), and the result: \n\n\u003cimg src=\"./output/cartoon_transfer_53_081680_overview.jpg\"\u003e\n\nSpecify the style image with `--style` and `--style_id` (find the mapping between id and filename [here](./data_preparation/id_filename_list.txt), find the visual mapping between id and the style image [here](./doc_images)). Specify the filename of the saved images with `--name`. Specify the weight to adjust the degree of style with `--weight`.\nThe following script generates the style transfer results in the teaser of the paper. \n```python\npython style_transfer.py\npython style_transfer.py --style cartoon --style_id 10\npython style_transfer.py --style caricature --name caricature_transfer --style_id 0 --weight 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\npython style_transfer.py --style caricature --name caricature_transfer --style_id 187 --weight 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\npython style_transfer.py --style anime --name anime_transfer --style_id 17 --weight 0 0 0 0 0.75 0.75 0.75 1 1 1 1 1 1 1 1 1 1 1\npython style_transfer.py --style anime --name anime_transfer --style_id 48 --weight 0 0 0 0 0.75 0.75 0.75 1 1 1 1 1 1 1 1 1 1 1\n```\n\nSpecify the content image with `--content`. If the content image is not well aligned with FFHQ, use `--align_face`. For preserving the color style of the content image, use `--preserve_color` or set the last 11 elements of `--weight` to all zeros.\n```python\npython style_transfer.py --content ./data/content/unsplash-rDEOVtE7vOs.jpg --align_face --preserve_color \\\n       --style arcane --name arcane_transfer --style_id 13 \\\n       --weight 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 1 1 1 1 1 1 1 \n```\n\n\u003cimg src=\"https://user-images.githubusercontent.com/18130694/159124661-fbb58871-7c7b-449f-95b5-83e44f5973e8.jpg\" width=\"32%\"\u003e → \u003cimg src=\"./output/arcane_transfer_13_unsplash-rDEOVtE7vOs_overview.jpg\" width=\"64%\"\u003e\n\nSpecify `--wplus` to use the original pSp encoder to extract the W+ intrinsic style code, which may better preserve the face features of the content image.\n\n**Remarks**: Our trained pSp encoder on Z+/W+ space cannot perfectly encode the content image. If the style transfer result more consistent with the content image is desired, one may use latent optimization to better fit the content image or using other StyleGAN encoders (as discussed in https://github.com/williamyang1991/DualStyleGAN/issues/11 and https://github.com/williamyang1991/DualStyleGAN/issues/29).\n\nMore options can be found via `python style_transfer.py  -h`.\n\n\n### Artistic Portrait Generation\nGenerate random Cartoon face images (Results are saved in the `./output/` folder):\n```python\npython generate.py \n```\n\nSpecify the style type with `--style` and the filename of the saved images with `--name`:\n```python\npython generate.py --style arcane --name arcane_generate\n```\n\nSpecify the weight to adjust the degree of style with `--weight`.\n\nKeep the intrinsic style code, extrinsic color code or extrinsic structure code fixed using `--fix_content`, `--fix_color` and `--fix_structure`, respectively.\n```python\npython generate.py --style caricature --name caricature_generate --weight 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 --fix_content\n```\n\nMore options can be found via `python generate.py -h`.\n\n\u003cbr/\u003e\n\n## (3) Training DualStyleGAN\n\nDownload the supporting models to the `./checkpoint/` folder:\n\n| Model | Description |\n| :--- | :--- |\n| [stylegan2-ffhq-config-f.pt](https://drive.google.com/file/d/1EM87UquaoQmk17Q8d5kYIAHqu0dkYqdT/view) | StyleGAN model trained on FFHQ taken from [rosinality](https://github.com/rosinality/stylegan2-pytorch). |\n| [model_ir_se50.pth](https://drive.google.com/file/d/1KW7bjndL3QG3sxBbZxreGHigcCCpsDgn/view?usp=sharing) | Pretrained IR-SE50 model taken from [TreB1eN](https://github.com/TreB1eN/InsightFace_Pytorch) for ID loss. |\n\n### Facial Destylization\n\n**Step 1: Prepare data.** Prepare the dataset in `./data/DATASET_NAME/images/train/`. First create lmdb datasets:\n```python\npython ./model/stylegan/prepare_data.py --out LMDB_PATH --n_worker N_WORKER --size SIZE1,SIZE2,SIZE3,... DATASET_PATH\n```\nFor example, download 317 Cartoon images into `./data/cartoon/images/train/` and run \n\u003e python ./model/stylegan/prepare_data.py --out ./data/cartoon/lmdb/ --n_worker 4 --size 1024 ./data/cartoon/images/\n\n**Step 2: Fine-tune StyleGAN.** Fine-tune StyleGAN in distributed settings:\n```python\npython -m torch.distributed.launch --nproc_per_node=N_GPU --master_port=PORT finetune_stylegan.py --batch BATCH_SIZE \\\n       --ckpt FFHQ_MODEL_PATH --iter ITERATIONS --style DATASET_NAME --augment LMDB_PATH\n```\nTake the cartoon dataset for example, run (batch size of 8\\*4=32 is recommended)\n\u003e python -m torch.distributed.launch --nproc_per_node=8 --master_port=8765 finetune_stylegan.py --iter 600\n                          --batch 4 --ckpt ./checkpoint/stylegan2-ffhq-config-f.pt --style cartoon\n                          --augment ./data/cartoon/lmdb/\n\nThe fine-tuned model can be found in `./checkpoint/cartoon/finetune-000600.pt`. Intermediate results are saved in `./log/cartoon/`.\n\n**Step 3: Destylize artistic portraits.** \n```python\npython destylize.py --model_name FINETUNED_MODEL_NAME --batch BATCH_SIZE --iter ITERATIONS DATASET_NAME\n```\nTake the cartoon dataset for example, run:\n\u003e python destylize.py --model_name finetune-000600.pt --batch 1 --iter 300 cartoon\n\nThe intrinsic and extrinsic style codes are saved in `./checkpoint/cartoon/instyle_code.npy` and `./checkpoint/cartoon/exstyle_code.npy`, respectively. Intermediate results are saved in `./log/cartoon/destylization/`.\nTo speed up destylization, set `--batch` to large value like 16. \nFor styles severely different from real faces, set `--truncation` to small value like 0.5 to make the results more photo-realistic (it enables DualStyleGAN to learn larger structrue deformations).\n\n\n### Progressive Fine-Tuning \n\n**Stage 1 \u0026 2: Pretrain DualStyleGAN on FFHQ.** \nWe provide our pretrained model [generator-pretrain.pt](https://drive.google.com/file/d/1j8sIvQZYW5rZ0v1SDMn2VEJFqfRjMW3f/view?usp=sharing) at [Google Drive](https://drive.google.com/drive/folders/1GZQ6Gs5AzJq9lUL-ldIQexi0JYPKNy8b?usp=sharing) or [Baidu Cloud](https://pan.baidu.com/s/1sOpPszHfHSgFsgw47S6aAA ) (access code: cvpr). This model is obtained by:\n\u003e python -m torch.distributed.launch --nproc_per_node=1 --master_port=8765 pretrain_dualstylegan.py --iter 3000\n                          --batch 4 ./data/ffhq/lmdb/\n\nwhere `./data/ffhq/lmdb/` contains the lmdb data created from the FFHQ dataset via `./model/stylegan/prepare_data.py`.\n\n**Stage 3: Fine-Tune DualStyleGAN on Target Domain.** Fine-tune DualStyleGAN in distributed settings:\n```python\npython -m torch.distributed.launch --nproc_per_node=N_GPU --master_port=PORT finetune_dualstylegan.py --iter ITERATIONS \\ \n                          --batch BATCH_SIZE --ckpt PRETRAINED_MODEL_PATH --augment DATASET_NAME\n```\nThe loss term weights can be specified by `--style_loss` (λ\u003csub\u003eFM\u003c/sub\u003e), `--CX_loss` (λ\u003csub\u003eCX\u003c/sub\u003e), `--perc_loss` (λ\u003csub\u003eperc\u003c/sub\u003e), `--id_loss` (λ\u003csub\u003eID\u003c/sub\u003e) and `--L2_reg_loss` (λ\u003csub\u003ereg\u003c/sub\u003e). λ\u003csub\u003eID\u003c/sub\u003e and λ\u003csub\u003ereg\u003c/sub\u003e are suggested to be tuned for each style dataset to achieve ideal performance. More options can be found via `python finetune_dualstylegan.py -h`.\n\nTake the Cartoon dataset as an example, run (multi-GPU enables a large batch size of 8\\*4=32 for better performance):\n\u003e python -m torch.distributed.launch --nproc_per_node=8 --master_port=8765 finetune_dualstylegan.py --iter 1500 --batch 4 --ckpt ./checkpoint/generator-pretrain.pt \n--style_loss 0.25 --CX_loss 0.25 --perc_loss 1 --id_loss 1 --L2_reg_loss 0.015 --augment cartoon\n\nThe fine-tuned models can be found in `./checkpoint/cartoon/generator-ITER.pt` where ITER = 001000, 001100, ..., 001500. Intermediate results are saved in `./log/cartoon/`. Large ITER has strong cartoon styles but at the cost of artifacts, and users may select the most balanced one from 1000-1500. We use 1400 for our paper experiments.\n\n### (optional) Latent Optimization and Sampling\n\n**Refine extrinsic style code.** Refine the color and structure styles to better fit the example style images.\n```python \npython refine_exstyle.py --lr_color COLOR_LEARNING_RATE --lr_structure STRUCTURE_LEARNING_RATE DATASET_NAME\n```\nBy default, the code will load `instyle_code.npy`, `exstyle_code.npy`, and `generator.pt` in `./checkpoint/DATASET_NAME/`. Use `--instyle_path`, `--exstyle_path`, `--ckpt` to specify other saved style codes or models. Take the Cartoon dataset as an example, run:\n\u003e python refine_exstyle.py --lr_color 0.1 --lr_structure 0.005 --ckpt ./checkpoint/cartoon/generator-001400.pt cartoon\n\nThe refined extrinsic style codes are saved in `./checkpoint/DATASET_NAME/refined_exstyle_code.npy`. `lr_color` and `lr_structure` are suggested to be tuned to better fit the example styles.\n\n**Training sampling network.** Train a sampling network to map unit Gaussian noises to the distribution of extrinsic style codes:\n```python\npython train_sampler.py DATASET_NAME\n```\nBy default, the code will load `refined_exstyle_code.npy` or `exstyle_code.npy` in `./checkpoint/DATASET_NAME/`. Use `--exstyle_path` to specify other saved extrinsic style codes. The saved model can be found in `./checkpoint/DATASET_NAME/sampler.pt`.\n\n\u003cbr/\u003e\n\n## (4) Results\n\n#### Exemplar-based cartoon style trasnfer\n\nhttps://user-images.githubusercontent.com/18130694/158047991-77c31137-c077-415e-bae2-865ed3ec021f.mp4\n\n#### Exemplar-based caricature style trasnfer\n\nhttps://user-images.githubusercontent.com/18130694/158048107-7b0aa439-5e3a-45a9-be0e-91ded50e9136.mp4\n\n#### Exemplar-based anime style trasnfer\n\nhttps://user-images.githubusercontent.com/18130694/158048114-237b8b81-eff3-4033-89f4-6e8a7bbf67f7.mp4\n\n#### Other styles\n\n\u003cimg src=\"https://user-images.githubusercontent.com/18130694/158049559-5450568f-170d-4847-88e1-d9bd12901966.jpg\" width=\"48%\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/18130694/158049562-e9971b49-ebd9-4300-bd08-34fc2473729f.jpg\" width=\"48%\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/18130694/158049563-72718807-4bef-472d-8875-71eee22ae934.jpg\" width=\"48%\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/18130694/158049565-0322a005-c402-40bc-8bef-9b22a8ca3fd4.jpg\" width=\"48%\"\u003e\n\n#### Combine DualStyleGAN with State-of-the-Art Diffusion model\n\nWe use [StableDiffusion](https://github.com/lowfuel/progrock-stable) to generate face images of the specified style of famous artists. \nTrained with these images, DualStyleGAN is able to pastiche these famous artists and generates appealing results.\n\n\n\u003cimg src=\"https://user-images.githubusercontent.com/18130694/191216968-dbd0df0e-c8b8-447b-9aa1-6edaad1685f9.jpg\" width=\"48%\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/18130694/191217109-7a9aba10-2cfc-4981-a499-9b95ccab8080.jpg\" width=\"48%\"\u003e\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/18130694/191217162-9eece58d-96ac-48f3-b521-b68b950cc503.jpg\" width=\"48%\"\u003e\n\u003c/div\u003e\n\n\n## Citation\n\nIf you find this work useful for your research, please consider citing our paper:\n\n```bibtex\n@inproceedings{yang2022Pastiche,\n  title={Pastiche Master: Exemplar-Based High-Resolution Portrait Style Transfer},\n  author={Yang, Shuai and Jiang, Liming and Liu, Ziwei and Loy, Chen Change},\n  booktitle={CVPR},\n  year={2022}\n}\n```\n\n## Acknowledgments\n\nThe code is mainly developed based on [stylegan2-pytorch](https://github.com/rosinality/stylegan2-pytorch) and [pixel2style2pixel](https://github.com/eladrich/pixel2style2pixel).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamyang1991%2FDualStyleGAN","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilliamyang1991%2FDualStyleGAN","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamyang1991%2FDualStyleGAN/lists"}