2022-08-17 01:21:13 +08:00
|
|
|
import cv2
|
|
|
|
import gradio as gr
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
def gif_maker():
|
|
|
|
img_array = []
|
|
|
|
height, width = 50, 50
|
|
|
|
for i in range(30):
|
|
|
|
img_array.append(np.random.randint(0, 255, size=(height, width, 3)).astype(np.uint8))
|
|
|
|
output_file = "test.mp4"
|
2024-08-07 08:55:38 +08:00
|
|
|
out = cv2.VideoWriter(output_file, cv2.VideoWriter_fourcc(*'mp4v'), 15, (height, width)) # type: ignore
|
2022-08-17 01:21:13 +08:00
|
|
|
for i in range(len(img_array)):
|
|
|
|
out.write(img_array[i])
|
|
|
|
out.release()
|
|
|
|
return output_file, output_file
|
|
|
|
|
|
|
|
demo = gr.Interface(gif_maker, inputs=None, outputs=[gr.Video(), gr.File()])
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2024-07-30 13:08:51 +08:00
|
|
|
demo.launch()
|