README.md 1.79 KB
Newer Older
Anton Lozhkov's avatar
Anton Lozhkov committed
1
2
## Training examples

3
4
Creating a training image set is [described in a different document](https://huggingface.co/docs/datasets/image_process#image-datasets).

anton-l's avatar
anton-l committed
5
6
7
8
9
10
11
12
### Installing the dependencies

Before running the scipts, make sure to install the library's training dependencies:

```bash
pip install diffusers[training] accelerate datasets
```

13
14
15
16
17
18
And initialize an [🤗Accelerate](https://github.com/huggingface/accelerate/) environment with:

```bash
accelerate config
```

anton-l's avatar
anton-l committed
19
### Unconditional Flowers  
Anton Lozhkov's avatar
Anton Lozhkov committed
20
21
22
23

The command to train a DDPM UNet model on the Oxford Flowers dataset:

```bash
24
accelerate launch train_unconditional.py \
Anton Lozhkov's avatar
Anton Lozhkov committed
25
26
  --dataset="huggan/flowers-102-categories" \
  --resolution=64 \
27
28
  --output_dir="ddpm-ema-flowers-64" \
  --train_batch_size=16 \
Anton Lozhkov's avatar
Anton Lozhkov committed
29
30
  --num_epochs=100 \
  --gradient_accumulation_steps=1 \
31
32
33
34
  --learning_rate=1e-4 \
  --lr_warmup_steps=500 \
  --mixed_precision=no \
  --push_to_hub
Anton Lozhkov's avatar
Anton Lozhkov committed
35
```
Anton Lozhkov's avatar
Anton Lozhkov committed
36
An example trained model: https://huggingface.co/anton-l/ddpm-ema-flowers-64
Anton Lozhkov's avatar
Anton Lozhkov committed
37

anton-l's avatar
anton-l committed
38
A full training run takes 2 hours on 4xV100 GPUs.
Anton Lozhkov's avatar
Anton Lozhkov committed
39

Anton Lozhkov's avatar
Anton Lozhkov committed
40
<img src="https://user-images.githubusercontent.com/26864830/180248660-a0b143d0-b89a-42c5-8656-2ebf6ece7e52.png" width="700" />
Anton Lozhkov's avatar
Anton Lozhkov committed
41
42


anton-l's avatar
anton-l committed
43
### Unconditional Pokemon 
Anton Lozhkov's avatar
Anton Lozhkov committed
44
45
46
47

The command to train a DDPM UNet model on the Pokemon dataset:

```bash
48
accelerate launch train_unconditional.py \
Anton Lozhkov's avatar
Anton Lozhkov committed
49
50
  --dataset="huggan/pokemon" \
  --resolution=64 \
51
52
  --output_dir="ddpm-ema-pokemon-64" \
  --train_batch_size=16 \
Anton Lozhkov's avatar
Anton Lozhkov committed
53
54
  --num_epochs=100 \
  --gradient_accumulation_steps=1 \
55
56
57
58
  --learning_rate=1e-4 \
  --lr_warmup_steps=500 \
  --mixed_precision=no \
  --push_to_hub
Anton Lozhkov's avatar
Anton Lozhkov committed
59
```
Anton Lozhkov's avatar
Anton Lozhkov committed
60
An example trained model: https://huggingface.co/anton-l/ddpm-ema-pokemon-64
Anton Lozhkov's avatar
Anton Lozhkov committed
61

anton-l's avatar
anton-l committed
62
A full training run takes 2 hours on 4xV100 GPUs.
Anton Lozhkov's avatar
Anton Lozhkov committed
63

Anton Lozhkov's avatar
Anton Lozhkov committed
64
<img src="https://user-images.githubusercontent.com/26864830/180248200-928953b4-db38-48db-b0c6-8b740fe6786f.png" width="700" />