ysharma HF staff commited on
Commit
44bf0f7
1 Parent(s): d950775

delete readme

Browse files
Files changed (1) hide show
  1. README.md +0 -154
README.md DELETED
@@ -1,154 +0,0 @@
1
- # pix2pix-zero
2
-
3
- ## [**[website]**](https://pix2pixzero.github.io/)
4
-
5
-
6
- This is author's reimplementation of "Zero-shot Image-to-Image Translation" using the diffusers library. <br>
7
- The results in the paper are based on the [CompVis](https://github.com/CompVis/stable-diffusion) library, which will be released later.
8
-
9
- **[New!]** Code for editing real and synthetic images released!
10
-
11
-
12
-
13
- <br>
14
- <div class="gif">
15
- <p align="center">
16
- <img src='assets/main.gif' align="center">
17
- </p>
18
- </div>
19
-
20
-
21
- We propose pix2pix-zero, a diffusion-based image-to-image approach that allows users to specify the edit direction on-the-fly (e.g., cat to dog). Our method can directly use pre-trained [Stable Diffusion](https://github.com/CompVis/stable-diffusion), for editing real and synthetic images while preserving the input image's structure. Our method is training-free and prompt-free, as it requires neither manual text prompting for each input image nor costly fine-tuning for each task.
22
-
23
- **TL;DR**: no finetuning required, no text input needed, input structure preserved.
24
-
25
- ## Results
26
- All our results are based on [stable-diffusion-v1-4](https://github.com/CompVis/stable-diffusion) model. Please the website for more results.
27
-
28
- <div>
29
- <p align="center">
30
- <img src='assets/results_teaser.jpg' align="center" width=800px>
31
- </p>
32
- </div>
33
- <hr>
34
-
35
- The top row for each of the results below show editing of real images, and the bottom row shows synthetic image editing.
36
- <div>
37
- <p align="center">
38
- <img src='assets/grid_dog2cat.jpg' align="center" width=800px>
39
- </p>
40
- <p align="center">
41
- <img src='assets/grid_zebra2horse.jpg' align="center" width=800px>
42
- </p>
43
- <p align="center">
44
- <img src='assets/grid_cat2dog.jpg' align="center" width=800px>
45
- </p>
46
- <p align="center">
47
- <img src='assets/grid_horse2zebra.jpg' align="center" width=800px>
48
- </p>
49
- <p align="center">
50
- <img src='assets/grid_tree2fall.jpg' align="center" width=800px>
51
- </p>
52
- </div>
53
-
54
- ## Real Image Editing
55
- <div>
56
- <p align="center">
57
- <img src='assets/results_real.jpg' align="center" width=800px>
58
- </p>
59
- </div>
60
-
61
- ## Synthetic Image Editing
62
- <div>
63
- <p align="center">
64
- <img src='assets/results_syn.jpg' align="center" width=800px>
65
- </p>
66
- </div>
67
-
68
- ## Method Details
69
-
70
- Given an input image, we first generate text captions using [BLIP](https://github.com/salesforce/LAVIS) and apply regularized DDIM inversion to obtain our inverted noise map.
71
- Then, we obtain reference cross-attention maps that correspoind to the structure of the input image by denoising, guided with the CLIP embeddings
72
- of our generated text (c). Next, we denoise with edited text embeddings, while enforcing a loss to match current cross-attention maps with the
73
- reference cross-attention maps.
74
-
75
- <div>
76
- <p align="center">
77
- <img src='assets/method.jpeg' align="center" width=900>
78
- </p>
79
- </div>
80
-
81
-
82
- ## Getting Started
83
-
84
- **Environment Setup**
85
- - We provide a [conda env file](environment.yml) that contains all the required dependencies
86
- ```
87
- conda env create -f environment.yml
88
- ```
89
- - Following this, you can activate the conda environment with the command below.
90
- ```
91
- conda activate pix2pix-zero
92
- ```
93
-
94
- **Real Image Translation**
95
- - First, run the inversion command below to obtain the input noise that reconstructs the image.
96
- The command below will save the inversion in the results folder as `output/test_cat/inversion/cat_1.pt`
97
- and the BLIP-generated prompt as `output/test_cat/prompt/cat_1.txt`
98
- ```
99
- python src/inversion.py \
100
- --input_image "assets/test_images/cats/cat_1.png" \
101
- --results_folder "output/test_cat"
102
- ```
103
- - Next, we can perform image editing with the editing direction as shown below.
104
- The command below will save the edited image as `output/test_cat/edit/cat_1.png`
105
- ```
106
- python src/edit_real.py \
107
- --inversion "output/test_cat/inversion/cat_1.pt" \
108
- --prompt "output/test_cat/prompt/cat_1.txt" \
109
- --task_name "cat2dog" \
110
- --results_folder "output/test_cat/"
111
- ```
112
-
113
- **Editing Synthetic Images**
114
- - Similarly, we can edit the synthetic images generated by Stable Diffusion with the following command.
115
- ```
116
- python src/edit_synthetic.py \
117
- --results_folder "output/synth_editing" \
118
- --prompt_str "a high resolution painting of a cat in the style of van gough" \
119
- --task "cat2dog"
120
- ```
121
-
122
- ### **Tips and Debugging**
123
- - **Controlling the Image Structure:**<br>
124
- The `--xa_guidance` flag controls the amount of cross-attention guidance to be applied when performing the edit. If the output edited image does not retain the structure from the input, increasing the value will typically address the issue. We recommend changing the value in increments of 0.05.
125
-
126
- - **Improving Image Quality:**<br>
127
- If the output image quality is low or has some artifacts, using more steps for both the inversion and editing would be helpful.
128
- This can be controlled with the `--num_ddim_steps` flag.
129
-
130
- - **Reducing the VRAM Requirements:**<br>
131
- We can reduce the VRAM requirements using lower precision and setting the flag `--use_float_16`.
132
-
133
- <br>
134
-
135
- **Finding Custom Edit Directions**<br>
136
- - We provide some pre-computed directions in the assets [folder](assets/embeddings_sd_1.4).
137
- To generate new edit directions, users can first generate two files containing a large number of sentences (~1000) and then run the command as shown below.
138
- ```
139
- python src/make_edit_direction.py \
140
- --file_source_sentences sentences/apple.txt \
141
- --file_target_sentences sentences/orange.txt \
142
- --output_folder assets/embeddings_sd_1.4
143
- ```
144
- - After running the above command, you can set the flag `--task apple2orange` for the new edit.
145
-
146
-
147
-
148
- ## Comparison
149
- Comparisons with different baselines, including, SDEdit + word swap, DDIM + word swap, and prompt-to-propmt. Our method successfully applies the edit, while preserving the structure of the input image.
150
- <div>
151
- <p align="center">
152
- <img src='assets/comparison.jpg' align="center" width=900>
153
- </p>
154
- </div>