multimodalart HF staff commited on
Commit
40eaef2
β€’
1 Parent(s): df3967c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -21
app.py CHANGED
@@ -20,21 +20,6 @@ pipe = FluxPipeline.from_pretrained(base_model,
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)
40
  # pipe.enable_model_cpu_offload()
@@ -117,13 +102,9 @@ def generate(prompt,
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
123
 
124
  def update_pre_generated_images(slider_value, total_images):
125
- print(total_images)
126
- print(slider_value)
127
  number_images = len(total_images)
128
  if(number_images > 0):
129
  scale_tuple = convert_to_centered_scale(number_images)
@@ -164,7 +145,7 @@ with gr.Blocks(css=css) as demo:
164
 
165
  x_concept_1 = gr.State("")
166
  x_concept_2 = gr.State("")
167
- total_images = gr.State([])
168
 
169
  avg_diff_x = gr.State()
170
 
 
20
  vae=taef1,
21
  torch_dtype=torch.bfloat16)
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  pipe.transformer.to(memory_format=torch.channels_last)
24
  # pipe.transformer = torch.compile(pipe.transformer, mode="max-autotune", fullgraph=True)
25
  # pipe.enable_model_cpu_offload()
 
102
  post_generation_slider_update = gr.update(label=comma_concepts_x, value=0, minimum=scale_min, maximum=scale_max, interactive=True)
103
  avg_diff_x = avg_diff.cpu()
104
 
105
+ return x_concept_1,x_concept_2, avg_diff_x, export_to_gif(images, "clip.gif", fps=5), canvas, images, images[scale_middle], post_generation_slider_update, seed
 
 
106
 
107
  def update_pre_generated_images(slider_value, total_images):
 
 
108
  number_images = len(total_images)
109
  if(number_images > 0):
110
  scale_tuple = convert_to_centered_scale(number_images)
 
145
 
146
  x_concept_1 = gr.State("")
147
  x_concept_2 = gr.State("")
148
+ total_images = gr.Gallery()
149
 
150
  avg_diff_x = gr.State()
151