2022-06-10 07:53:41 +08:00
|
|
|
import cv2
|
|
|
|
import gradio as gr
|
|
|
|
|
|
|
|
def gif_maker(img_files):
|
|
|
|
img_array = []
|
2024-07-20 09:34:34 +08:00
|
|
|
size = (1, 1)
|
2022-06-10 07:53:41 +08:00
|
|
|
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"
|
2024-08-07 08:55:38 +08:00
|
|
|
out = cv2.VideoWriter(output_file,cv2.VideoWriter_fourcc(*'h264'), 15, size) # type: ignore
|
2022-06-10 07:53:41 +08:00
|
|
|
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__":
|
2024-07-30 13:08:51 +08:00
|
|
|
demo.launch()
|