File size: 3,780 Bytes
8377658
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Installation

- [System Requirements](#system-requirements)
- [Install with PyPI](#install-with-pypi)
- [Install Manually](#install-manually)
- [Install with Docker](#install-with-docker)

## System requirements

- This implementation support running on CPU, Nvidia GPU, and Apple's m1/m2 chips. 
- When using with GPU, 8 GB memory is required for 1024 models. 6 GB is recommended for 512 models.


## Install with PyPI

πŸ“‘ [Step by Step Tutorial](https://zeqiang-lai.github.io/blog/en/posts/drag_gan/) | [中文部署教程](https://zeqiang-lai.github.io/blog/posts/ai/drag_gan/)

We recommend to use Conda to install requirements.

```bash
conda create -n draggan python=3.7
conda activate draggan
```

Install PyTorch following the [official instructions](https://pytorch.org/get-started/locally/)
```bash
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia 
```

Install DragGAN
```bash
pip install draggan
# If you meet ERROR: Could not find a version that satisfies the requirement draggan (from versions: none), use
pip install draggan -i https://pypi.org/simple/
```

Launch the Gradio demo

```bash
# if you have a Nvidia GPU
python -m draggan.web
# if you use m1/m2 mac
python -m draggan.web --device mps
# otherwise
python -m draggan.web --device cpu
```

## Install Manually

Ensure you have a GPU and CUDA installed. We use Python 3.7 for testing, other versions (>= 3.7) of Python should work too, but not tested. We recommend to use [Conda](https://conda.io/projects/conda/en/stable/user-guide/install/download.html) to prepare all the requirements.

For Windows users, you might encounter some issues caused by StyleGAN custom ops, youd could find some solutions from the [issues pannel](https://github.com/Zeqiang-Lai/DragGAN/issues). We are also working on a more friendly package without setup.

```bash
git clone https://github.com/Zeqiang-Lai/DragGAN.git
cd DragGAN
conda create -n draggan python=3.7
conda activate draggan
pip install -r requirements.txt
```

Launch the Gradio demo

```bash
# if you have a Nvidia GPU
python gradio_app.py
# if you use m1/m2 mac
python gradio_app.py --device mps
# otherwise
python gradio_app.py --device cpu
```

> If you have any issue for downloading the checkpoint, you could manually download it from [here](https://huggingface.co/aaronb/StyleGAN2/tree/main) and put it into the folder `checkpoints`.

## Install with Docker

Follow these steps to run DragGAN using Docker:

### Prerequisites

1. Install Docker on your system from the [official Docker website](https://www.docker.com/).
2. Ensure that your system has [NVIDIA Docker support](https://github.com/NVIDIA/nvidia-docker) if you are using GPUs.

### Run using docker Hub image

```bash
  # For GPU
  docker run -t -p 7860:7860 --gpus all baydarov/draggan
```

```bash
  # For CPU only (not recommended)
  docker run -t -p 7860:7860 baydarov/draggan --device cpu
```

### Step-by-step Guide with building image locally

1. Clone the DragGAN repository and build the Docker image:

```bash
   git clone https://github.com/Zeqiang-Lai/DragGAN.git # clone repo
   cd DragGAN                                           # change into the repo directory
   docker build -t draggan .                            # build image
```

2. Run the DragGAN Docker container:

```bash
  # For GPU
  docker run -t -p 7860:7860 --gpus all draggan
```

```bash
  # For CPU (not recommended)
  docker run -t -p 7860:7860 draggan --device cpu
```

3. The DragGAN Web UI will be accessible once you see the following output in your console:

```
  ...
  Running on local URL: http://0.0.0.0:7860
  ...
```

Visit [http://localhost:7860](http://localhost:7860/) to access the Web UI.

That's it! You're now running DragGAN in a Docker container.