Ahsen Khaliq commited on
Commit
73529df
β€’
1 Parent(s): 10b0dff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -351,9 +351,14 @@ def inference(text, seed, step_size, max_iterations, width, height, init_image,
351
  pbar.update()
352
  except KeyboardInterrupt:
353
  pass
354
- all_frames[0].save('out.gif',
355
- save_all=True, append_images=all_frames[1:], optimize=False, duration=80, loop=0)
356
- return image, 'out.gif'
 
 
 
 
 
357
  def load_image( infilename ) :
358
  img = Image.open( infilename )
359
  img.load()
@@ -374,7 +379,7 @@ gr.Interface(
374
  gr.inputs.Slider(minimum=0.0, maximum=15.0, default=0.0, label='Initial Weight', step=1.0),
375
  gr.inputs.Image(type="file", label="Target Image (Optional)", optional=True)
376
  ],
377
- [gr.outputs.Image(type="numpy", label="Output Image"),gr.outputs.Image(type="file", label="Output GIF")],
378
  title=title,
379
  description=description,
380
  article=article,
 
351
  pbar.update()
352
  except KeyboardInterrupt:
353
  pass
354
+ writer = imageio.get_writer('test.mp4', fps=20)
355
+
356
+ for im in all_frames:
357
+ writer.append_data(imageio.imread(im))
358
+ writer.close()
359
+ # all_frames[0].save('out.gif',
360
+ # save_all=True, append_images=all_frames[1:], optimize=False, duration=80, loop=0)
361
+ return image, 'test.mp4'
362
  def load_image( infilename ) :
363
  img = Image.open( infilename )
364
  img.load()
 
379
  gr.inputs.Slider(minimum=0.0, maximum=15.0, default=0.0, label='Initial Weight', step=1.0),
380
  gr.inputs.Image(type="file", label="Target Image (Optional)", optional=True)
381
  ],
382
+ [gr.outputs.Image(type="numpy", label="Output Image"),gr.outputs.Video(label="Output Video")],
383
  title=title,
384
  description=description,
385
  article=article,