Update app.py
Browse files
app.py
CHANGED
@@ -94,15 +94,15 @@ def create_video(frames, fps, type):
|
|
94 |
return type + "_result.mp4"
|
95 |
|
96 |
|
97 |
-
def infer(
|
98 |
|
99 |
fps_output = logscale(fps_output)
|
100 |
# 1. break video into frames and get FPS
|
101 |
-
break_vid = get_frames(url_in, "vid_input_frame", "origin", resize_n)
|
102 |
-
frames_list = break_vid[0]
|
103 |
-
fps = break_vid[1]
|
104 |
print(f"ORIGIN FPS: {fps}")
|
105 |
-
n_frame = int(
|
106 |
#n_frame = len(frames_list)
|
107 |
|
108 |
if n_frame >= len(frames_list):
|
@@ -117,7 +117,7 @@ def infer(url_in,interpolation,fps_output,resize_n):
|
|
117 |
if idx < len(frames_list) - 1:
|
118 |
next_frame = frames_list[idx+1]
|
119 |
|
120 |
-
interpolated_frames = do_interpolation(frame, next_frame, interpolation) # should return a list of 3 interpolated frames
|
121 |
break_interpolated_video = get_frames(interpolated_frames, "interpol", f"{idx}_", 0)
|
122 |
print(break_interpolated_video[0])
|
123 |
for j, img in enumerate(break_interpolated_video[0][0:len(break_interpolated_video[0])-1]):
|
@@ -164,7 +164,7 @@ title="""
|
|
164 |
|
165 |
</div>
|
166 |
<p> This space uses FILM to generate interpolation frames in a video you need to 'tween'.<br />
|
167 |
-
Generation is limited to
|
168 |
<a style="display:inline-block" href="https://huggingface.co/spaces/freealise/video_frame_interpolation?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a>
|
169 |
</p>
|
170 |
</div>
|
@@ -175,10 +175,8 @@ with gr.Blocks() as demo:
|
|
175 |
gr.HTML(title)
|
176 |
with gr.Row():
|
177 |
with gr.Column():
|
178 |
-
|
179 |
-
video_input =
|
180 |
-
video_input.change(fn=loadurl, inputs=[video_input], outputs=[url_input])
|
181 |
-
resize_num = gr.Slider(minimum=1, maximum=4096, step=1, value=256, label="Resize to width: ")
|
182 |
with gr.Row():
|
183 |
interpolation_slider = gr.Slider(minimum=1, maximum=5, step=1, value=0, label="Interpolation Steps: ")
|
184 |
interpolation = gr.Number(value=1, show_label=False, interactive=False)
|
@@ -194,13 +192,13 @@ with gr.Blocks() as demo:
|
|
194 |
file_output = gr.File()
|
195 |
|
196 |
gr.Examples(
|
197 |
-
examples=[["./examples/
|
198 |
fn=infer,
|
199 |
-
inputs=[
|
200 |
outputs=[video_output, file_output],
|
201 |
cache_examples=True
|
202 |
)
|
203 |
|
204 |
-
submit_btn.click(fn=infer, inputs=[
|
205 |
|
206 |
demo.launch()
|
|
|
94 |
return type + "_result.mp4"
|
95 |
|
96 |
|
97 |
+
def infer(glr_in, interpolation, fps_output):
|
98 |
|
99 |
fps_output = logscale(fps_output)
|
100 |
# 1. break video into frames and get FPS
|
101 |
+
#break_vid = get_frames(url_in, "vid_input_frame", "origin", resize_n)
|
102 |
+
frames_list = glr_in #break_vid[0]
|
103 |
+
fps = 1 #break_vid[1]
|
104 |
print(f"ORIGIN FPS: {fps}")
|
105 |
+
n_frame = int(300) #limited to 300 frames
|
106 |
#n_frame = len(frames_list)
|
107 |
|
108 |
if n_frame >= len(frames_list):
|
|
|
117 |
if idx < len(frames_list) - 1:
|
118 |
next_frame = frames_list[idx+1]
|
119 |
|
120 |
+
interpolated_frames = do_interpolation(frame[0], next_frame[0], interpolation) # should return a list of 3 interpolated frames
|
121 |
break_interpolated_video = get_frames(interpolated_frames, "interpol", f"{idx}_", 0)
|
122 |
print(break_interpolated_video[0])
|
123 |
for j, img in enumerate(break_interpolated_video[0][0:len(break_interpolated_video[0])-1]):
|
|
|
164 |
|
165 |
</div>
|
166 |
<p> This space uses FILM to generate interpolation frames in a video you need to 'tween'.<br />
|
167 |
+
Generation is limited to 300 frames, from the beginning of your video input.<br />
|
168 |
<a style="display:inline-block" href="https://huggingface.co/spaces/freealise/video_frame_interpolation?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a>
|
169 |
</p>
|
170 |
</div>
|
|
|
175 |
gr.HTML(title)
|
176 |
with gr.Row():
|
177 |
with gr.Column():
|
178 |
+
gallery_input = gr.Gallery(label="Slides", preview=True, columns=8192)
|
179 |
+
#video_input.change(fn=loadurl, inputs=[video_input], outputs=[url_input])
|
|
|
|
|
180 |
with gr.Row():
|
181 |
interpolation_slider = gr.Slider(minimum=1, maximum=5, step=1, value=0, label="Interpolation Steps: ")
|
182 |
interpolation = gr.Number(value=1, show_label=False, interactive=False)
|
|
|
192 |
file_output = gr.File()
|
193 |
|
194 |
gr.Examples(
|
195 |
+
examples=[[[("./examples/0.png","0"), ("./examples/1.png","1"), ("./examples/2.png","2"), ("./examples/3.png","3"), ("./examples/4.png","4")], 0, 0]],
|
196 |
fn=infer,
|
197 |
+
inputs=[gallery_input, interpolation_slider, fps_output_slider],
|
198 |
outputs=[video_output, file_output],
|
199 |
cache_examples=True
|
200 |
)
|
201 |
|
202 |
+
submit_btn.click(fn=infer, inputs=[gallery_input, interpolation_slider, fps_output_slider], outputs=[video_output, file_output])
|
203 |
|
204 |
demo.launch()
|