alkzar90 commited on
Commit
0f566a4
1 Parent(s): 22a86e1

Init model repo

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ images/ddpo-church-incompressibility-samples.png filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,56 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - pytorch
5
+ - diffusers
6
+ - unconditional-image-generation
7
+ ---
8
+
9
+ # Finetuning `ddpm-church-256` model with DDPO for JPEG incompressibility enhancement
10
+
11
+ ![](https://huggingface.co/alkzar90/ddpo-incompressibility-celebahq-256/resolve/main/images/over50_47png)
12
+
13
+
14
+ **DDPO Paper**: [Training Diffusion Models with Reinforcement Learning](https://arxiv.org/abs/2305.13301)
15
+
16
+ **Authors**: Kevin Black, Michael Janner, Yilun Du, Ilya Kostrikov, Sergey Levine
17
+
18
+ **Abstract**:
19
+
20
+ *Diffusion models are a class of flexible generative models trained with an approximation to the log-likelihood objective. However, most use cases of diffusion models are not concerned with likelihoods, but instead with downstream objectives such as human-perceived image quality or drug effectiveness. In this paper, we investigate reinforcement learning methods for directly optimizing diffusion models for such objectives. We describe how posing denoising as a multi-step decision-making problem enables a class of policy gradient algorithms, which we refer to as denoising diffusion policy optimization (DDPO), that are more effective than alternative reward-weighted likelihood approaches. Empirically, DDPO is able to adapt text-to-image diffusion models to objectives that are difficult to express via prompting, such as image compressibility, and those derived from human feedback, such as aesthetic quality. Finally, we show that DDPO can improve prompt-image alignment using feedback from a vision-language model without the need for additional data collection or human annotation. The project's website can be found at [this http URL](https://rl-diffusion.github.io/).*
21
+
22
+ ## Inference
23
+
24
+ **DDPM** based models can use *discrete noise schedulers* such as:
25
+
26
+ - [scheduling_ddpm](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddpm.py)
27
+ - [scheduling_ddim](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddim.py)
28
+ - [scheduling_pndm](https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_pndm.py)
29
+
30
+ for inference. Note that while the *ddpm* scheduler yields the highest quality, it also takes the longest.
31
+ For a good trade-off between quality and inference speed you might want to consider the *ddim* or *pndm* schedulers instead.
32
+
33
+ See the following code:
34
+
35
+ ```python
36
+ # !pip install diffusers
37
+ from diffusers import DDPMPipeline, DDIMPipeline, PNDMPipeline
38
+
39
+ model_id = "alkzar90/ddpo-incompressibility-church-256"
40
+
41
+ # load model and scheduler
42
+ ddpm = DDPMPipeline.from_pretrained(model_id) # you can replace DDPMPipeline with DDIMPipeline or PNDMPipeline for faster inference
43
+
44
+ # run pipeline in inference (sample random noise and denoise)
45
+ image = ddpm().images[0]
46
+
47
+ # save image
48
+ image.save("ddpo_church_generated_image.png")
49
+ ```
50
+
51
+ For more in-detail information, please have a look at the [official inference example](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/diffusers_intro.ipynb).
52
+
53
+ ## Samples
54
+
55
+ ![Church 256x256 generated samples from the DDPO finetuned model optimized by
56
+ JPEG incompressibility](https://huggingface.co/alkzar90/ddpo-incompressibility-church-256/resolve/main/images/ddpo-church-incompressibility-samples.png)
config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "UNet2DModel",
3
+ "_diffusers_version": "0.0.4",
4
+ "act_fn": "silu",
5
+ "attention_head_dim": null,
6
+ "block_out_channels": [
7
+ 128,
8
+ 128,
9
+ 256,
10
+ 256,
11
+ 512,
12
+ 512
13
+ ],
14
+ "center_input_sample": false,
15
+ "down_block_types": [
16
+ "DownBlock2D",
17
+ "DownBlock2D",
18
+ "DownBlock2D",
19
+ "DownBlock2D",
20
+ "AttnDownBlock2D",
21
+ "DownBlock2D"
22
+ ],
23
+ "downsample_padding": 0,
24
+ "flip_sin_to_cos": false,
25
+ "freq_shift": 1,
26
+ "in_channels": 3,
27
+ "layers_per_block": 2,
28
+ "mid_block_scale_factor": 1,
29
+ "norm_eps": 1e-06,
30
+ "norm_num_groups": 32,
31
+ "out_channels": 3,
32
+ "sample_size": 256,
33
+ "time_embedding_type": "positional",
34
+ "up_block_types": [
35
+ "UpBlock2D",
36
+ "AttnUpBlock2D",
37
+ "UpBlock2D",
38
+ "UpBlock2D",
39
+ "UpBlock2D",
40
+ "UpBlock2D"
41
+ ]
42
+ }
diffusion_pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b63d1cf7bce8bbd1269cff455f1555bd63e22e3be004fe112a6cdc5a3f2171cd
3
+ size 454876602
images/.DS_Store ADDED
Binary file (6.15 kB). View file
 
images/ddpo-church-incompressibility-samples.png ADDED

Git LFS Details

  • SHA256: 42184ac5d989ea5dcf25d9cf78b8f948ed5e9bb33b6add3d0a317a0ded2b08d8
  • Pointer size: 132 Bytes
  • Size of remote file: 2.28 MB
model_index.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "DDPMPipeline",
3
+ "_diffusers_version": "0.0.4",
4
+ "scheduler": [
5
+ "diffusers",
6
+ "DDPMScheduler"
7
+ ],
8
+ "unet": [
9
+ "diffusers",
10
+ "UNet2DModel"
11
+ ]
12
+ }
scheduler_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "DDPMScheduler",
3
+ "_diffusers_version": "0.1.1",
4
+ "beta_end": 0.02,
5
+ "beta_schedule": "linear",
6
+ "beta_start": 0.0001,
7
+ "clip_sample": true,
8
+ "num_train_timesteps": 1000,
9
+ "trained_betas": null,
10
+ "variance_type": "fixed_small"
11
+ }