Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -187,7 +187,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
187 |
with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16), timer("inference"):
|
188 |
try:
|
189 |
generated_image = pipe(
|
190 |
-
prompt=[formatted_prompt],
|
191 |
generator=torch.Generator().manual_seed(int(seed)),
|
192 |
num_inference_steps=int(steps),
|
193 |
guidance_scale=float(scales),
|
@@ -200,31 +200,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
200 |
if saved_path is None:
|
201 |
print("Warning: Failed to save generated image")
|
202 |
|
203 |
-
return generated_image
|
204 |
except Exception as e:
|
205 |
print(f"Error in image generation: {str(e)}")
|
206 |
-
return None
|
207 |
-
|
208 |
-
|
209 |
|
210 |
def update_seed():
|
211 |
return get_random_seed()
|
212 |
|
213 |
generate_btn.click(
|
214 |
process_and_save_image,
|
215 |
-
inputs=[height, width, steps, scales, prompt, seed],
|
216 |
-
outputs=[output, gallery]
|
217 |
-
)
|
218 |
-
|
219 |
-
randomize_seed.click(
|
220 |
-
update_seed,
|
221 |
-
outputs=[seed]
|
222 |
-
)
|
223 |
-
|
224 |
-
generate_btn.click(
|
225 |
-
update_seed,
|
226 |
-
outputs=[seed]
|
227 |
-
)
|
228 |
-
|
229 |
-
if __name__ == "__main__":
|
230 |
-
demo.launch(allowed_paths=[PERSISTENT_DIR])
|
|
|
187 |
with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16), timer("inference"):
|
188 |
try:
|
189 |
generated_image = pipe(
|
190 |
+
prompt=[formatted_prompt],
|
191 |
generator=torch.Generator().manual_seed(int(seed)),
|
192 |
num_inference_steps=int(steps),
|
193 |
guidance_scale=float(scales),
|
|
|
200 |
if saved_path is None:
|
201 |
print("Warning: Failed to save generated image")
|
202 |
|
203 |
+
return generated_image
|
204 |
except Exception as e:
|
205 |
print(f"Error in image generation: {str(e)}")
|
206 |
+
return None
|
|
|
|
|
207 |
|
208 |
def update_seed():
|
209 |
return get_random_seed()
|
210 |
|
211 |
generate_btn.click(
|
212 |
process_and_save_image,
|
213 |
+
inputs=[height, width, steps, scales, prompt, seed],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|