Official Code for DragGAN (SIGGRAPH 2023)
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Xingang Pan 2ffd0bf226
Merge pull request #117 from merryHunter/feat/simple-docker-support
feat: added simple Dockerfile to quickly run Gradio app
2 years ago
dnnlib DragGAN code 2 years ago
gradio_utils support gradio demo for DragGAN 2 years ago
gui_utils DragGAN code 2 years ago
scripts added windows GUI bat file 2 years ago
stylegan_human Support & instructions for MPS (Silicon Mac M1/M2) and CPU 2 years ago
torch_utils DragGAN code 2 years ago
training DragGAN code 2 years ago
viz Fix UnboundLocalError 2 years ago
.gitignore modified .gitignore 2 years ago
Dockerfile feat: added simple Dockerfile to quickly run gradio app and instructions; fixed version in pip requirements.txt 2 years ago
DragGAN.gif first commit 2 years ago
LICENSE.txt DragGAN code 2 years ago
README.md feat: added simple Dockerfile to quickly run gradio app and instructions; fixed version in pip requirements.txt 2 years ago
arial.ttf support gradio demo for DragGAN 2 years ago
environment.yml Support & instructions for MPS (Silicon Mac M1/M2) and CPU 2 years ago
gen_images.py Support & instructions for MPS (Silicon Mac M1/M2) and CPU 2 years ago
legacy.py DragGAN code 2 years ago
requirements.txt feat: added simple Dockerfile to quickly run gradio app and instructions; fixed version in pip requirements.txt 2 years ago
visualizer_drag.py Actual fixes for resetting mask and saving w. 2 years ago
visualizer_drag_gradio.py Update visualizer_drag_gradio.py 2 years ago

README.md

Drag Your GAN: Interactive Point-based Manipulation on the Generative Image Manifold

Xingang Pan · Ayush Tewari · Thomas Leimkühler · Lingjie Liu · Abhimitra Meka · Christian Theobalt

SIGGRAPH 2023 Conference Proceedings


PyTorch Twitter Paper PDF Project Page Open In Colab

Web Demos

Open in OpenXLab

Huggingface

Requirements

If you have CUDA graphic card, please follow the requirements of NVlabs/stylegan3.

The usual installation steps involve the following commands, they should set up the correct CUDA version and all the python packages

conda env create python=3.7 -f environment.yml
conda activate stylegan3

Then install the additional requirements

pip install -r requirements

Otherwise (for GPU acceleration on MacOS with Silicon Mac M1/M2, or just CPU) try the following:

cat environment.yml | \
  grep -v -E 'nvidia|cuda' > environment-no-nvidia.yml && \
    conda env create -f environment-no-nvidia.yml
conda activate stylegan3

Run Gradio visualizer in Docker

Provided docker image is based on NGC PyTorch repository. To quickly try out visualizer in Docker, run the following:

docker build . -t draggan:latest  
docker run -v  "$PWD":/workspace/src -it draggan:latest bash  
cd src && python visualizer_drag_gradio.py  

Now you can open a shared link from Gradio (printed in the terminal console).
Beware the Docker image takes about 25GB of disk space!

On MacOS

export PYTORCH_ENABLE_MPS_FALLBACK=1


## Download pre-trained StyleGAN2 weights

To download pre-trained weights, simply run:
```sh
sh scripts/download_model.sh

If you want to try StyleGAN-Human and the Landscapes HQ (LHQ) dataset, please download weights from these links: StyleGAN-Human, LHQ, and put them under ./checkpoints.

Feel free to try other pretrained StyleGAN.

Run DragGAN GUI

To start the DragGAN GUI, simply run:

sh scripts/gui.sh

This GUI supports editing GAN-generated images. To edit a real image, you need to first perform GAN inversion using tools like PTI. Then load the new latent code and model weights to the GUI.

You can run DragGAN Gradio demo as well:

python visualizer_drag_gradio.py

Acknowledgement

This code is developed based on StyleGAN3. Part of the code is borrowed from StyleGAN-Human.

License

The code related to the DragGAN algorithm is licensed under CC-BY-NC. However, most of this project are available under a separate license terms: all codes used or modified from StyleGAN3 is under the Nvidia Source Code License.

Any form of use and derivative of this code must preserve the watermarking functionality showing "AI Generated".

BibTeX

@inproceedings{pan2023draggan,
    title={Drag Your GAN: Interactive Point-based Manipulation on the Generative Image Manifold},
    author={Pan, Xingang and Tewari, Ayush, and Leimk{\"u}hler, Thomas and Liu, Lingjie and Meka, Abhimitra and Theobalt, Christian},
    booktitle = {ACM SIGGRAPH 2023 Conference Proceedings},
    year={2023}
}