fffiloni commited on
Commit
38f9ea8
·
1 Parent(s): 74b681f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -6
app.py CHANGED
@@ -65,13 +65,16 @@ def create_video(frames, fps, type):
65
 
66
  return type + "_result.mp4"
67
 
68
-
69
- def infer(imported_gif):
70
  clip = VideoFileClip(imported_gif.name)
71
  clip.write_videofile("my_gif_video.mp4")
 
 
 
 
72
 
73
  # 1. break video into frames and get FPS
74
- break_vid = get_frames("my_gif_video.mp4")
75
  frames_list= break_vid[0]
76
  fps = break_vid[1]
77
  #n_frame = int(trim_value*fps)
@@ -97,6 +100,18 @@ def infer(imported_gif):
97
 
98
  return final_vid, files
99
 
100
- inputs = [gr.File(label="import a GIF instead", file_types=['.gif'])]
101
- outputs = [gr.Video(),gr.Files()]
102
- gr.Interface(fn=infer, inputs=inputs, outputs=outputs).launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  return type + "_result.mp4"
67
 
68
+ def convertG2V(imported_gif):
 
69
  clip = VideoFileClip(imported_gif.name)
70
  clip.write_videofile("my_gif_video.mp4")
71
+ return "my_gif_video.mp4"
72
+
73
+ def infer(video_in):
74
+
75
 
76
  # 1. break video into frames and get FPS
77
+ break_vid = get_frames(video_in)
78
  frames_list= break_vid[0]
79
  fps = break_vid[1]
80
  #n_frame = int(trim_value*fps)
 
100
 
101
  return final_vid, files
102
 
103
+ with gr.Blocks() as demo:
104
+ with gr.Row():
105
+ with gr.Column():
106
+ video_input = gr.Video(source="upload", type="filepath")
107
+ gif_input = gr.File(label="import a GIF instead", file_types=['.gif'])
108
+ gif_input.change(fn=convertG2V, gif_input, video_input)
109
+ submit_btn = gr.Button("Submit")
110
+
111
+ with gr.Column():
112
+ video_output = gr.Video()
113
+ file_output = gr.Files()
114
+
115
+ submit_btn.click(fn=infer, inputs=[video_input], outputs=[video_output, file_output])
116
+
117
+ demo.launch()