Giter Club home page Giter Club logo

scenimefy's Introduction

Scenimefy: Learning to Craft Anime Scene via Semi-Supervised Image-to-Image Translation

MMLab@NTU affiliated with S-Lab, Nanyang Technological University
In ICCV 2023.

πŸ“ƒPaper | 🌐Project Page | πŸ“‚Anime Scene Dataset | πŸ€—Demo



Updates

  • [11/2023] Train code is available.
  • [08/2023] Integrated to Hugging Face. Enjoy the web demo!
  • [08/2023] Inference code and Dataset is released.
  • [08/2023] Project page is built.
  • [07/2023] The paper is accepted to ICCV 2023!

πŸ”§ Installation

  1. Clone this repo:
    git clone https://github.com/Yuxinn-J/Scenimefy.git
    cd Scenimefy
  2. Install dependent packages: After installing Anaconda, create a new Conda environment using conda env create -f Semi_translation/environment.yml.

⚑ Quick Inference

  1. Python script 2. Gradio demo

Python script

  • Download pre-trained models: Shinkai_net_G.pth

    wget https://github.com/Yuxinn-J/Scenimefy/releases/download/v0.1.0/Shinkai_net_G.pth -P Semi_translation/pretrained_models/shinkai-test/
  • Inference! Simply run the following command, or refer the ./Semi_translation/script/test.sh for detailed usage:

    cd Semi_translation
    
    python test.py --dataroot ./datasets/Sample --name shinkai-test --CUT_mode CUT  --model cut --phase test --epoch Shinkai --preprocess none
    • Results will be saved in ./Semi_translation/results/shinkai-test/ by default.
    • To prepare your own test images, you can refer to the data folder structure in ./Semi_translation/datasets/Sample, and place your test images in testA.

Gradio demo

  • We provide a UI for testing Scenimefy, which is built with gradio. To launch the demo, simply execute the following command in your terminal:
    git clone https://huggingface.co/spaces/YuxinJ/Scenimefy
    pip install -r requirements.txt
    pip install gradio
    python app.py
    
  • This demo is also hosted on Hugging FaceπŸ€—.

πŸš‹ Quick I2I Train

Dataset Preparation

  • LHQ dataset: a dataset of 90,000 nature landscape images [downlaod link]. Place it in ./datasets/unpaired_s2a, and rename as trainA.
  • Anime dataset: 5,958 shinkai-style anime scene images. Please follow the instructions in Anime_dataset/README.md. Place it in ./datasets/unpaired_s2a, and rename as trainB.
  • Pseudo-paired dataset: 30,000 synthetic pseudo paired images generated from StyleGAN with the same seed. You may finetune your own StyleGAN or use our provided data [downlaod link] for quick start. Place them in ./datasets/pair_s2a
  • Create your own dataset

Training

Refer to the ./Semi_translation/script/train.sh file, or use the following command:

python train.py --name exp_shinkai  --CUT_mode CUT --model semi_cut \ 
--dataroot ./datasets/unpaired_s2a --paired_dataroot ./datasets/pair_s2a \ 
--checkpoints_dir ./pretrained_models \
--dce_idt --lambda_VGG -1  --lambda_NCE_s 0.05 \ 
--use_curriculum  --gpu_ids 0
  • If the anime dataset quality is low, consider add a global perceptual loss to maintain content consistency, e.g., set --lambda_VGG 0.2.

🏁 Start From Scratch

StyleGAN Finetuning [TODO]

Segmenation Selection

πŸ“‚ Anime Scene Dataset

anime-dataset It is a high-quality anime scene dataset comprising 5,958 images with the following features:

  • High-resolution (1080Γ—1080)
  • Shinkai-style (from 9 Mokota Shinkai films)
  • Pure anime scene: manual dataset curation by eliminating irrelevant and low-quality images

In compliance with copyright regulations, we cannot directly release the anime images. However, you can conveniently prepare the dataset following instructions here.

🀟 Citation

If you find this work useful for your research, please consider citing our paper:

@inproceedings{jiang2023scenimefy,
  title={Scenimefy: Learning to Craft Anime Scene via Semi-Supervised Image-to-Image Translation},
  author={Jiang, Yuxin and Jiang, Liming and Yang, Shuai and Loy, Chen Change},
  booktitle={ICCV},
  year={2023}
}

πŸ€— Acknowledgments

Our code is mainly developed based on Cartoon-StyleGAN and Hneg_SRC. We thank facebook for their contribution of Mask2Former.

πŸ—žοΈ License

Distributed under the S-Lab License. See LICENSE.md for more information.

scenimefy's People

Contributors

eltociear avatar endlesssora avatar yuxinn-j avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scenimefy's Issues

about test output?

Thanks for your work,

  1. Will you post more models
  2. The test portrait effect is very poor, why?

Missing training script

In the README there are the instructions on how to train a custom model. It says to run train.py, but this file is missing.

Model training

Could you please tell me how to train your model for this code?

test dataset

Where can I get your test dataset you mentioned in your paper?

How to process a video?

From the project web, those demo videos look very stable and amazing. How to process a video? Just extract a video to frames and process frames one by one? Or there is other stability tech?

About the StylePatchNCE loss code?

Hi, thank you for your greate work! But I don't find where the StylePatchNCE loss, can you help me? I'm looking forward your repying.

Hello, I have a question: why are real_A and real_B spliced ​​together when training unpaired images, but there is no such step when training paired images?

Hello, I have a question: why are real_A and real_B spliced ​​together when training unpaired images, but there is no such step when training paired images?
"""
Run forward pass; called by both functions <optimize_parameters> and ."""
self.real = torch.cat((self.real_A, self.real_B),
dim=0) if self.opt.dce_idt and self.opt.isTrain else self.real_A
if self.opt.flip_equivariance:
self.flipped_for_equivariance = self.opt.isTrain and (np.random.random() < 0.5)
if self.flipped_for_equivariance:
self.real = torch.flip(self.real, [3])

    # forward unpaired data
    self.fake = self.netG(self.real)
    self.fake_B = self.fake[:self.real_A.size(0)]
    if self.opt.dce_idt:
        self.idt_B = self.fake[self.real_A.size(0):]

    # forward paired data
    self.fake_p = self.netG(self.real_A_p)
    self.fake_B_p = self.fake_p[:self.real_A_p.size(0)]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.