Code Monkey home page Code Monkey logo

soat's Introduction

StyleGAN of All Trades: Image Manipulation with Only Pretrained StyleGAN

This is the PyTorch implementation of StyleGAN of All Trades: Image Manipulation with Only Pretrained StyleGAN. Open In Colab

Web Demo Integrated to Huggingface Spaces with Gradio. See demo for Panorama Generation for Landscapes: Hugging Face Spaces

Abstract:
Recently, StyleGAN has enabled various image manipulation and editing tasks thanks to the high-quality generation and the disentangled latent space. However, additional architectures or task-specific training paradigms are usually required for different tasks. In this work, we take a deeper look at the spatial properties of StyleGAN. We show that with a pretrained StyleGAN along with some operations, without any additional architecture, we can perform comparably to the state-of-the-art methods on various tasks, including image blending, panorama generation, generation from a single image, controllable and local multimodal image to image translation, and attributes transfer.

How to use

Everything to get started is in the colab notebook.

Toonification

For toonification, you can train a new model yourself by running

python train.py

For disney toonification, we use the disney dataset here. Feel free to experiment with different datasets.

GAN inversion

To perform GAN inversion with gaussian regularization in W+ space,

python projector.py xxx.jpg

the code will be saved in ./inversion_codes/xxx.pt which you can load by

source = load_source(['xxx'], generator, device)
source_im, _ = generator(source)

Citation

If you use this code or ideas from our paper, please cite our paper:

@article{chong2021stylegan,
  title={StyleGAN of All Trades: Image Manipulation with Only Pretrained StyleGAN},
  author={Chong, Min Jin and Lee, Hsin-Ying and Forsyth, David},
  journal={arXiv preprint arXiv:2111.01619},
  year={2021}
}

Acknowledgments

This code borrows from StyleGAN2 by rosalinity

soat's People

Contributors

ak391 avatar mchong6 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  avatar

soat's Issues

StyleGAN inversion

Hello! Thanks for the work done, the results look great. I was particularly impressed by your image inversion, but I am not quite sure how it works. Do you plan to publish the relevant code?

Stuck on the Colab execution.

When I start running the colab file, it stop responding in

freeman@freeman-T430s:~/SOAT/models/research$ python -m pip install -q .
  DEPRECATION: A future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend you use --use-feature=in-tree-build to test your packages with this new behavior before it becomes the default.
   pip 21.3 will remove support for this functionality. You can find discussion regarding this at https://github.com/pypa/pip/issues/7555.

^CERROR: Operation cancelled by user

It occurs on my local laptop too. What should I do ?

Transfer multiple features from image to image using bbox

I'd like to annotate and transfer multiple bboxes from the target image to the source image. I noticed in running infinity.ipynb that while I can use Colab to annotate multiple bboxes on the target, only the first of them gets transferred from the source.

This behavior seems consistent with the blend_bbox code in model.py where only the first bbox (coord[0]) is being considered and the rest don't seem to be processed.

Two questions - a) am I missing something here and b) if the above is accurate, is it useful if I add an outer loop to enable blend_bbox to iterate thru the bbox_list

CUDA Out Of Memory in Distributed Training

I used to successfully train the StyleGAN2-ADA and StyleGAN3 on my device. However the distributed training for SOAT failed due to out of the cuda memory. I modify the code a little bit which don't involving any training codes, then I use the Slurm to submit my training job to the server and check the model has been successfully distributed to different GPUs. Before the first epoch completes, the job aborts.
The information below is my training environment:
    CPU: Intel Xeon 6348
    GPU: NVIDIA A100 40G PCIe*8
    Script:  python -m torch.distributed.launch --nproc_per_node=8 train.py --dataset=[My Dataset(Grayscale in 1024x1024, and I convert it into RGB when loading dataset)] --batch=X --size=1024 --iter=40000
BTW, I set the batch size as 64, 32, 16. All of them abort. When I using a single GPU to train the SOAT with batch size 8, it succeeds.
Looking for your reply and see if there's any possible solution.

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.