mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-27 01:40:20 +08:00
Fix multiple file upload (#1512)
* changes * Update utils.ts Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
c6ab13210e
commit
f41ebdd616
1
demo/gif_maker/requirements.txt
Normal file
1
demo/gif_maker/requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
opencv-python
|
23
demo/gif_maker/run.py
Normal file
23
demo/gif_maker/run.py
Normal file
@ -0,0 +1,23 @@
|
||||
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()
|
Binary file not shown.
@ -45,7 +45,9 @@
|
||||
data: this.result as string
|
||||
}
|
||||
: (this.result as string);
|
||||
if (all_file_data.length === files.length) {
|
||||
if (
|
||||
all_file_data.filter((x) => x !== undefined).length === files.length
|
||||
) {
|
||||
dispatch(
|
||||
"load",
|
||||
file_count == "single" ? all_file_data[0] : all_file_data
|
||||
|
Loading…
Reference in New Issue
Block a user