ZachNagengast commited on
Commit
3300b67
1 Parent(s): 16852a7
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -7,7 +7,7 @@ import tempfile
7
 
8
  global stored_frames
9
 
10
- def load_and_store_frames(image_file):
11
  global stored_frames
12
 
13
  # Make sure file exists
@@ -32,11 +32,15 @@ def load_and_store_frames(image_file):
32
  convert_gif_to_video(image_file.name, tmp_file.name, 1 / (img.info.get('duration', 100) / 1000.0))
33
 
34
  stored_frames = frames # Store the frames for later use
35
- return "Frames loaded successfully", video_path
 
 
 
 
36
 
37
  def generate_grid(grid_x, grid_y, font_size, font_color, position, border_size, border_color):
38
  global stored_frames
39
- print(f"Processing grid with {grid_x} x {grid_y} grid size, font size {font_size}, font color {font_color}, position {position}, border size {border_size}, border color {border_color}")
40
 
41
  if stored_frames is None:
42
  load_and_store_frames()
@@ -194,7 +198,7 @@ with gr.Blocks() as app:
194
  result_image = gr.Image(label="Generated Grid")
195
 
196
  # Use .change() method to listen for changes in any of the controls
197
- control_image.upload(load_and_store_frames, inputs=[control_image], outputs=[gif_details, video_preview])
198
 
199
  # grid_x_slider.change(generate_grid, inputs=[grid_x_slider, grid_y_slider, font_size_slider, font_color_dropdown, position_radio, border_size_slider, border_color_dropdown], outputs=[result_image, gif_details, video_preview])
200
  # grid_y_slider.change(generate_grid, inputs=[grid_x_slider, grid_y_slider, font_size_slider, font_color_dropdown, position_radio, border_size_slider, border_color_dropdown], outputs=[result_image, gif_details])
 
7
 
8
  global stored_frames
9
 
10
+ def load_and_store_frames(image_file, grid_x, grid_y):
11
  global stored_frames
12
 
13
  # Make sure file exists
 
32
  convert_gif_to_video(image_file.name, tmp_file.name, 1 / (img.info.get('duration', 100) / 1000.0))
33
 
34
  stored_frames = frames # Store the frames for later use
35
+ total_frames = len(frames)
36
+ selected_frames_count = grid_x * grid_y
37
+ details = f"**Total Frames:** {len(frames)}\n\n"
38
+ output_info = f"Grid size: {grid_x} x {grid_y}\n\nSelected Frames: {selected_frames_count} / {total_frames} ({selected_frames_count / total_frames * 100:.2f}%)"
39
+ return f"Frames loaded successfully\n\n{details}\n\n{output_info}", video_path
40
 
41
  def generate_grid(grid_x, grid_y, font_size, font_color, position, border_size, border_color):
42
  global stored_frames
43
+ # print(f"Processing grid with {grid_x} x {grid_y} grid size, font size {font_size}, font color {font_color}, position {position}, border size {border_size}, border color {border_color}")
44
 
45
  if stored_frames is None:
46
  load_and_store_frames()
 
198
  result_image = gr.Image(label="Generated Grid")
199
 
200
  # Use .change() method to listen for changes in any of the controls
201
+ control_image.upload(load_and_store_frames, inputs=[control_image, grid_x_slider, grid_y_slider], outputs=[gif_details, video_preview])
202
 
203
  # grid_x_slider.change(generate_grid, inputs=[grid_x_slider, grid_y_slider, font_size_slider, font_color_dropdown, position_radio, border_size_slider, border_color_dropdown], outputs=[result_image, gif_details, video_preview])
204
  # grid_y_slider.change(generate_grid, inputs=[grid_x_slider, grid_y_slider, font_size_slider, font_color_dropdown, position_radio, border_size_slider, border_color_dropdown], outputs=[result_image, gif_details])