linoyts HF Staff commited on
Commit
55fc94b
·
verified ·
1 Parent(s): faedcba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -104,29 +104,32 @@ def invert_and_edit(image,
104
  width=1024,
105
  guidance_scale=1,
106
  output_type="pil",
107
- num_inference_steps=50,
108
  max_sequence_length=512,
109
  latents=image2latent(image),
110
  invert_image=True
111
  )
112
  do_inversion = False
113
-
114
-
 
115
  output = pipe(
116
  [source_prompt, edit_prompt],
117
  height=1024,
118
  width=1024,
119
  guidance_scale=[1,3],
120
  output_type="pil",
121
- num_inference_steps=50,
122
  max_sequence_length=512,
123
  latents=inverted_latent_list[-1].tile(2, 1, 1),
124
  inverted_latent_list=inverted_latent_list,
125
  mm_copy_blocks=MULTIMODAL_VITAL_LAYERS,
126
  single_copy_blocks=SINGLE_MODAL_VITAL_LAYERS,
127
  ).images[1]
128
-
129
- return output, inverted_latent_list.cpu(), do_inversion, seed
 
 
130
 
131
  # UI CSS
132
  css = """
@@ -193,7 +196,7 @@ following the algorithm proposed in [*Stable Flow: Vital Layers for Training-Fre
193
  minimum=1,
194
  maximum=50,
195
  step=1,
196
- value=18,
197
  )
198
 
199
 
@@ -204,7 +207,7 @@ following the algorithm proposed in [*Stable Flow: Vital Layers for Training-Fre
204
  minimum=1,
205
  maximum=50,
206
  step=1,
207
- value=50,
208
  )
209
 
210
  with gr.Row():
 
104
  width=1024,
105
  guidance_scale=1,
106
  output_type="pil",
107
+ num_inference_steps=num_inversion_steps,
108
  max_sequence_length=512,
109
  latents=image2latent(image),
110
  invert_image=True
111
  )
112
  do_inversion = False
113
+ else:
114
+ # move to gpu because of zero and gr.states
115
+ inverted_latent_list = [tensor.to(DEVICE) for tensor in inverted_latent_list]
116
  output = pipe(
117
  [source_prompt, edit_prompt],
118
  height=1024,
119
  width=1024,
120
  guidance_scale=[1,3],
121
  output_type="pil",
122
+ num_inference_steps=num_inference_steps,
123
  max_sequence_length=512,
124
  latents=inverted_latent_list[-1].tile(2, 1, 1),
125
  inverted_latent_list=inverted_latent_list,
126
  mm_copy_blocks=MULTIMODAL_VITAL_LAYERS,
127
  single_copy_blocks=SINGLE_MODAL_VITAL_LAYERS,
128
  ).images[1]
129
+
130
+ # move back to cpu because of zero and gr.states
131
+ inverted_latent_list = [tensor.cpu() for tensor in inverted_latent_list]
132
+ return output, inverted_latent_list, do_inversion, seed
133
 
134
  # UI CSS
135
  css = """
 
196
  minimum=1,
197
  maximum=50,
198
  step=1,
199
+ value=25,
200
  )
201
 
202
 
 
207
  minimum=1,
208
  maximum=50,
209
  step=1,
210
+ value=25,
211
  )
212
 
213
  with gr.Row():