Spaces:
Runtime error
Runtime error
jadechoghari
commited on
Commit
β’
1efb400
1
Parent(s):
7e59139
Update app.py
Browse files
app.py
CHANGED
@@ -7,10 +7,10 @@ from torchao.quantization import autoquant
|
|
7 |
|
8 |
|
9 |
# # normal FluxPipeline
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
# optimized FluxPipeline
|
16 |
pipeline_optimized = FluxPipeline.from_pretrained(
|
@@ -38,7 +38,6 @@ for name, layer in pipeline_optimized.transformer.named_children():
|
|
38 |
# pipeline_optimized.transformer,
|
39 |
# error_on_unseen=False
|
40 |
# )
|
41 |
-
pipeline_normal = pipeline_optimized
|
42 |
|
43 |
@spaces.GPU(duration=120)
|
44 |
def generate_images(prompt, guidance_scale, num_inference_steps):
|
@@ -49,15 +48,14 @@ def generate_images(prompt, guidance_scale, num_inference_steps):
|
|
49 |
num_inference_steps=int(num_inference_steps)
|
50 |
).images[0]
|
51 |
|
52 |
-
#
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
return image_normal
|
61 |
|
62 |
# set up Gradio interface
|
63 |
demo = gr.Interface(
|
@@ -69,7 +67,7 @@ demo = gr.Interface(
|
|
69 |
],
|
70 |
outputs=[
|
71 |
gr.Image(type="pil", label="Normal FluxPipeline"),
|
72 |
-
|
73 |
],
|
74 |
title="FluxPipeline Comparison",
|
75 |
description="Compare images generated by the normal FluxPipeline and the optimized one using torchao and torch.compile()."
|
|
|
7 |
|
8 |
|
9 |
# # normal FluxPipeline
|
10 |
+
pipeline_normal = FluxPipeline.from_pretrained(
|
11 |
+
"sayakpaul/FLUX.1-merged",
|
12 |
+
torch_dtype=torch.bfloat16
|
13 |
+
).to("cuda")
|
14 |
|
15 |
# optimized FluxPipeline
|
16 |
pipeline_optimized = FluxPipeline.from_pretrained(
|
|
|
38 |
# pipeline_optimized.transformer,
|
39 |
# error_on_unseen=False
|
40 |
# )
|
|
|
41 |
|
42 |
@spaces.GPU(duration=120)
|
43 |
def generate_images(prompt, guidance_scale, num_inference_steps):
|
|
|
48 |
num_inference_steps=int(num_inference_steps)
|
49 |
).images[0]
|
50 |
|
51 |
+
# generate image with optimized pipeline
|
52 |
+
image_optimized = pipeline_optimized(
|
53 |
+
prompt=prompt,
|
54 |
+
guidance_scale=guidance_scale,
|
55 |
+
num_inference_steps=int(num_inference_steps)
|
56 |
+
).images[0]
|
57 |
|
58 |
+
return image_normal, image_optimized
|
|
|
59 |
|
60 |
# set up Gradio interface
|
61 |
demo = gr.Interface(
|
|
|
67 |
],
|
68 |
outputs=[
|
69 |
gr.Image(type="pil", label="Normal FluxPipeline"),
|
70 |
+
gr.Image(type="pil", label="Optimized FluxPipeline")
|
71 |
],
|
72 |
title="FluxPipeline Comparison",
|
73 |
description="Compare images generated by the normal FluxPipeline and the optimized one using torchao and torch.compile()."
|