Giter VIP home page Giter VIP logo

animeganv2_pytorch's Introduction

AnimeGANv2_Pytorch 中文

Reference source AnimeGANv2 project, rewritten with Pytorch to implement

Installation and testing environment

GPU:3060 batch_size=10 训练耗时为13min/epoch

  • torch==1.10.1
  • pytorch-lightning==1.7.7
  • wandb
  • tqdm==4.64.0
  • PyYAML
  • opencv-python==4.5.5.64

Usage

Initialization training

python train.py --config_path config/config-init.yaml --init_train_flag True
  • --config_path The path of the configuration file, default is config/config-init.yaml
  • ---init_train_flag whether to initialize the training, if True, the generator network with the specified epoch will be trained according to the configuration file, the discriminator network will not be trained. After training, the weights of the generator network will be saved and used for subsequent finetune training.

Formal training

python train.py --config_path config/config-defaults.yaml --init_train_flag False --pre_train_weight checkpoint/initAnimeGan/Hayao/epoch\=4-step\=3330-v1.ckpt
  • --config_path The path to the configuration file, default is config/config-defaults.yaml
  • ---init_train_flag whether to initialize the training, if False, the generator network and discriminator network will be trained according to the config file for the specified epoch
  • --pre_train_weight Pre-train weights, you can load the initialized generator network weights for finetune training, and then train them into a new model
  • --resume_ckpt_path breakpoint training, you can load the previously trained model to continue training

Testing

python test.py --model_dir checkpoint/animeGan/Hayao/epoch=59-step=79920-v1.ckpt --test_file_path "dataset/test/HR_photo/1 (55).jpg"
  • --model_dir Model path
  • --test_file_path Test image path

Export Model

python export_model.py --checkpoint_path checkpoint/animeGan/Hayao/epoch=59-step=79920-v1.ckpt --dynamic
  • --checkpoint_path Model path
  • --onnx whether to export the onnx model
  • --pytorch whether to export the pytorch model
  • --torchscript whether to export the torchscript model
  • --dynamic whether to export input with dynamic dimensions on onnx model

Training process

loss variation

Discriminator related losses

image-20220624202624359

Generator related losses

image-20220624202832128

Relative change in loss of generators and discriminators

image-20220624202944846

As can be seen from the loss, the generator and discriminator produced an obvious confrontation effect, the generator loss into an upward trend, discriminator loss into a downward trend, due to the training of the relevant loss weight is in accordance with the way recommended by the original author, and the original author training effect has a certain difference, you need to adjust again

Image verification results

图片1

pic2

pic3

License

  • This version is for academic research and non-commercial use only, if used for commercial purposes, please contact me for licensing approval

animeganv2_pytorch's People

Contributors

jiyegege avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

animeganv2_pytorch's Issues

Create a W&B account?

AttributeError: 'VGGCaffePreTrained' object has no attribute 'features'
wandb: Waiting for W&B process to finish... (failed 1).
wandb: You can sync this run to the cloud by running:
wandb: wandb sync ./wandb/offline-run-20230318_194510-3tktpfql
wandb: Find logs at: ./wandb/offline-run-20230318_194510-3tktpfql/logs

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.