gradio/demo/gif_maker/run.py
Abubakar Abid d7c96e1ad8
Adds a demo to show how a sound alert can be played when a prediction is complete (#2478)
* add sound alert demo

* changelog

* update changelog

* address suggestions
2022-10-18 13:03:07 -07:00

21 lines
601 B
Python

import cv2
import gradio as gr
def gif_maker(img_files):
img_array = []
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()