Spaces:
Runtime error
Runtime error
Commit
β’
df3967c
1
Parent(s):
86be4e6
Update app.py
Browse files
app.py
CHANGED
@@ -20,10 +20,20 @@ pipe = FluxPipeline.from_pretrained(base_model,
|
|
20 |
vae=taef1,
|
21 |
torch_dtype=torch.bfloat16)
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
pipe.transformer.to(memory_format=torch.channels_last)
|
29 |
# pipe.transformer = torch.compile(pipe.transformer, mode="max-autotune", fullgraph=True)
|
@@ -107,7 +117,6 @@ def generate(prompt,
|
|
107 |
post_generation_slider_update = gr.update(label=comma_concepts_x, value=0, minimum=scale_min, maximum=scale_max, interactive=True)
|
108 |
avg_diff_x = avg_diff.cpu()
|
109 |
|
110 |
-
os.makedirs("frames", exist_ok=True)
|
111 |
image_paths = save_images_with_unique_filenames(images, "frames")
|
112 |
|
113 |
return x_concept_1,x_concept_2, avg_diff_x, export_to_gif(images, "clip.gif", fps=5), canvas, image_paths, images[scale_middle], post_generation_slider_update, seed
|
|
|
20 |
vae=taef1,
|
21 |
torch_dtype=torch.bfloat16)
|
22 |
|
23 |
+
os.makedirs("frames", exist_ok=True)
|
24 |
+
def save_images_with_unique_filenames(image_list, save_directory):
|
25 |
+
if not os.path.exists(save_directory):
|
26 |
+
os.makedirs(save_directory)
|
27 |
+
|
28 |
+
paths = []
|
29 |
+
for image in image_list:
|
30 |
+
unique_filename = f"{uuid.uuid4()}.png"
|
31 |
+
file_path = os.path.join(save_directory, unique_filename)
|
32 |
+
image.save(file_path)
|
33 |
+
paths.append(file_path)
|
34 |
+
|
35 |
+
return paths
|
36 |
+
|
37 |
|
38 |
pipe.transformer.to(memory_format=torch.channels_last)
|
39 |
# pipe.transformer = torch.compile(pipe.transformer, mode="max-autotune", fullgraph=True)
|
|
|
117 |
post_generation_slider_update = gr.update(label=comma_concepts_x, value=0, minimum=scale_min, maximum=scale_max, interactive=True)
|
118 |
avg_diff_x = avg_diff.cpu()
|
119 |
|
|
|
120 |
image_paths = save_images_with_unique_filenames(images, "frames")
|
121 |
|
122 |
return x_concept_1,x_concept_2, avg_diff_x, export_to_gif(images, "clip.gif", fps=5), canvas, image_paths, images[scale_middle], post_generation_slider_update, seed
|