Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
tags:
|
4 |
+
- stable-diffusion
|
5 |
+
- stable-diffusion-diffusers
|
6 |
+
- image-to-image
|
7 |
+
- art
|
8 |
+
widget:
|
9 |
+
- src: >-
|
10 |
+
https://hf.co/datasets/sayakpaul/sample-datasets/resolve/main/derain%20the%20image_1.png
|
11 |
+
prompt: derain the image
|
12 |
+
datasets:
|
13 |
+
- instruction-tuning-sd/low-level-image-proc
|
14 |
+
---
|
15 |
+
|
16 |
+
# Instruction-tuned Stable Diffusion for Low-level Image Processing (Fine-tuned)
|
17 |
+
|
18 |
+
("This pipeline is an 'instruction-tuned' version of [Stable Diffusion (v1.5)](https://huggingface.co/runwayml/stable-diffusion-v1-5). It was fine-tuned from the existing [InstructPix2Pix checkpoints](https://huggingface.co/timbrooks/instruct-pix2pix).",)
|
19 |
+
|
20 |
+
## Pipeline description
|
21 |
+
|
22 |
+
Motivation behind this pipeline partly comes from [FLAN](https://huggingface.co/papers/2109.01652) and partly
|
23 |
+
comes from [InstructPix2Pix](https://huggingface.co/papers/2211.09800). The main idea is to first create an
|
24 |
+
instruction prompted dataset (as described in [our blog](https://hf.co/blog/instruction-tuning-sd)) and then conduct InstructPix2Pix style
|
25 |
+
training. The end objective is to make Stable Diffusion better at following specific instructions
|
26 |
+
that entail image transformation related operations.
|
27 |
+
|
28 |
+
<p align="center">
|
29 |
+
<img src="https://huggingface.co/datasets/sayakpaul/sample-datasets/resolve/main/instruction-tuning-sd.png" width=600/>
|
30 |
+
</p>
|
31 |
+
|
32 |
+
Follow [this post](https://hf.co/blog/instruction-tuning-sd) to know more.
|
33 |
+
|
34 |
+
## Training procedure and results
|
35 |
+
|
36 |
+
Training was conducted on [instruction-tuning-sd/low-level-image-proc](https://huggingface.co/datasets/instruction-tuning-sd/low-level-image-proc) dataset. Refer to
|
37 |
+
[this repository](https://github.com/sayakpaul/instruction-tuned-sd) to know more.
|
38 |
+
|
39 |
+
Here are some results dervied from the pipeline:
|
40 |
+
|
41 |
+
(TODO)
|
42 |
+
|
43 |
+
## Intended uses & limitations
|
44 |
+
|
45 |
+
You can use the pipeline for performing low-level image processing with an input image and an input prompt.
|
46 |
+
|
47 |
+
### How to use
|
48 |
+
|
49 |
+
Here is how to use this model:
|
50 |
+
|
51 |
+
```python
|
52 |
+
import torch
|
53 |
+
from diffusers import StableDiffusionInstructPix2PixPipeline
|
54 |
+
from diffusers.utils import load_image
|
55 |
+
|
56 |
+
model_id = "instruction-tuning-sd/scratch-low-level-img-proc"
|
57 |
+
pipeline = StableDiffusionInstructPix2PixPipeline.from_pretrained(
|
58 |
+
model_id, torch_dtype=torch.float16, use_auth_token=True
|
59 |
+
).to("cuda")
|
60 |
+
|
61 |
+
image_path = "https://hf.co/datasets/sayakpaul/sample-datasets/resolve/main/derain%20the%20image_1.png"
|
62 |
+
image = load_image(image_path)
|
63 |
+
|
64 |
+
image = pipeline("derain the image", image=image).images[0]
|
65 |
+
image.save("image.png")
|
66 |
+
```
|
67 |
+
|
68 |
+
For notes on limitations, misuse, malicious use, out-of-scope use, please refer to the model card
|
69 |
+
[here](https://huggingface.co/runwayml/stable-diffusion-v1-5).
|
70 |
+
|
71 |
+
## Citation
|
72 |
+
|
73 |
+
**FLAN**
|
74 |
+
|
75 |
+
```bibtex
|
76 |
+
@inproceedings{
|
77 |
+
wei2022finetuned,
|
78 |
+
title={Finetuned Language Models are Zero-Shot Learners},
|
79 |
+
author={Jason Wei and Maarten Bosma and Vincent Zhao and Kelvin Guu and Adams Wei Yu and Brian Lester and Nan Du and Andrew M. Dai and Quoc V Le},
|
80 |
+
booktitle={International Conference on Learning Representations},
|
81 |
+
year={2022},
|
82 |
+
url={https://openreview.net/forum?id=gEZrGCozdqR}
|
83 |
+
}
|
84 |
+
```
|
85 |
+
|
86 |
+
**InstructPix2Pix**
|
87 |
+
|
88 |
+
```bibtex
|
89 |
+
@InProceedings{
|
90 |
+
brooks2022instructpix2pix,
|
91 |
+
author = {Brooks, Tim and Holynski, Aleksander and Efros, Alexei A.},
|
92 |
+
title = {InstructPix2Pix: Learning to Follow Image Editing Instructions},
|
93 |
+
booktitle = {CVPR},
|
94 |
+
year = {2023},
|
95 |
+
}
|
96 |
+
```
|
97 |
+
|
98 |
+
**Instruction-tuning for Stable Diffusion blog**
|
99 |
+
|
100 |
+
```bibtex
|
101 |
+
@article{
|
102 |
+
Paul2023instruction-tuning-sd,
|
103 |
+
author = {Paul, Sayak},
|
104 |
+
title = {Instruction-tuning Stable Diffusion with InstructPix2Pix},
|
105 |
+
journal = {Hugging Face Blog},
|
106 |
+
year = {2023},
|
107 |
+
note = {https://huggingface.co/blog/instruction-tuning-sd},
|
108 |
+
}
|
109 |
+
```
|