gradio/demo/gif_maker/run.py
aliabid94 f41ebdd616
Fix multiple file upload (#1512)
* changes

* Update utils.ts

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
2022-06-09 16:53:41 -07:00

23 lines
631 B
Python

import cv2
import gradio as gr
import tempfile
def gif_maker(img_files):
img_array = []
import os
for filename in img_files:
img = cv2.imread(filename.name)
height, width, _ = img.shape
size = (width,height)
img_array.append(img)
output_file = "test.mp4"
out = cv2.VideoWriter(output_file,cv2.VideoWriter_fourcc(*'h264'), 15, size)
for i in range(len(img_array)):
out.write(img_array[i])
out.release()
return output_file
demo = gr.Interface(gif_maker, inputs=gr.File(file_count="multiple"), outputs=gr.Video())
if __name__ == "__main__":
demo.launch()