nagolinc commited on
Commit
b4df60b
·
1 Parent(s): 4a695d8

add duration slider

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -96,7 +96,7 @@ def compute_offsets(reference, images, window_size):
96
  #peak_x = -peak_x
97
  #peak_y = -peak_y
98
 
99
- print(peak_x, peak_y)
100
 
101
  # Compute the offset in the range [-window_size, window_size]
102
  if peak_x > correlation.shape[0] // 2:
@@ -234,7 +234,7 @@ def create_aligned_gif(original_image, columns_per_row, window_size=200, duratio
234
 
235
  return output_gif_path
236
 
237
- def wrapper_func(img, columns_per_row_str):
238
  #img = Image.open(BytesIO(file))
239
 
240
  #img = Image.fromarray(img_arr)
@@ -242,10 +242,7 @@ def wrapper_func(img, columns_per_row_str):
242
  columns_per_row = [int(x.strip()) for x in columns_per_row_str.split(',')]
243
  output_gif_path = 'output.gif'
244
 
245
-
246
- print("about to die",img,columns_per_row)
247
-
248
- create_aligned_gif(img, columns_per_row)
249
  #with open(output_gif_path, "rb") as f:
250
  #return base64.b64encode(f.read()).decode()
251
  # Image.open(output_gif_path)
@@ -269,10 +266,11 @@ iface = gr.Interface(
269
  fn=wrapper_func,
270
  inputs=[
271
  gr.components.Image(label="Upload Spritesheet",type='pil'),
272
- gr.components.Textbox(label="Columns per Row", default="3,4,3")
 
273
  ],
274
  outputs=gr.components.Image(type="filepath", label="Generated GIF"),
275
- examples=[[example_image, example_columns_per_row]], # Adding examples here
276
  live=False,
277
  server_name="Hugging Face Spaces",
278
  server_port=80,
 
96
  #peak_x = -peak_x
97
  #peak_y = -peak_y
98
 
99
+ #print(peak_x, peak_y)
100
 
101
  # Compute the offset in the range [-window_size, window_size]
102
  if peak_x > correlation.shape[0] // 2:
 
234
 
235
  return output_gif_path
236
 
237
+ def wrapper_func(img, columns_per_row_str,duration):
238
  #img = Image.open(BytesIO(file))
239
 
240
  #img = Image.fromarray(img_arr)
 
242
  columns_per_row = [int(x.strip()) for x in columns_per_row_str.split(',')]
243
  output_gif_path = 'output.gif'
244
 
245
+ create_aligned_gif(img, columns_per_row,duration=duration)
 
 
 
246
  #with open(output_gif_path, "rb") as f:
247
  #return base64.b64encode(f.read()).decode()
248
  # Image.open(output_gif_path)
 
266
  fn=wrapper_func,
267
  inputs=[
268
  gr.components.Image(label="Upload Spritesheet",type='pil'),
269
+ gr.components.Textbox(label="Columns per Row", default="3,4,3"),
270
+ gr.components.Slider(minimum=10, maximum=1000, step=10, value=100, label="Duration of each frame (ms)"),
271
  ],
272
  outputs=gr.components.Image(type="filepath", label="Generated GIF"),
273
+ examples=[[example_image, example_columns_per_row,100]], # Adding examples here
274
  live=False,
275
  server_name="Hugging Face Spaces",
276
  server_port=80,