jbilcke-hf commited on
Commit
8bb0ac4
·
1 Parent(s): 1223437

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -15
app.py CHANGED
@@ -24,8 +24,8 @@ interpolator = interpolator.Interpolator(model, None)
24
  ffmpeg_path = util.get_ffmpeg_path()
25
  mediapy.set_ffmpeg(ffmpeg_path)
26
 
 
27
 
28
-
29
  def do_interpolation(frame1, frame2, times_to_interpolate):
30
  print(frame1, frame2)
31
  input_frames = [frame1, frame2]
@@ -84,8 +84,10 @@ def create_video(frames, fps, type):
84
  return type + "_result.mp4"
85
 
86
 
87
- def infer(video_in,interpolation,fps_output):
88
 
 
 
89
 
90
  # 1. break video into frames and get FPS
91
  break_vid = get_frames(video_in, "vid_input_frame", "origin")
@@ -129,21 +131,23 @@ def infer(video_in,interpolation,fps_output):
129
  title="""test space"""
130
 
131
  with gr.Blocks() as demo:
132
- with gr.Column():
133
- gr.HTML(title)
134
- with gr.Row():
135
- with gr.Column():
136
- video_input = gr.Video(source="upload", type="filepath")
137
- with gr.Row():
138
- interpolation = gr.Slider(minimum=1,maximum=4,step=1, value=3, label="Interpolation Steps")
139
- fps_output = gr.Radio([8, 12, 24], label="FPS output", value=24)
140
- submit_btn = gr.Button("Submit")
 
 
 
141
 
142
- with gr.Column():
143
- video_output = gr.Video()
144
- file_output = gr.File()
145
 
146
 
147
- submit_btn.click(fn=infer, inputs=[video_input,interpolation,fps_output], outputs=[video_output, file_output])
148
 
149
  demo.launch()
 
24
  ffmpeg_path = util.get_ffmpeg_path()
25
  mediapy.set_ffmpeg(ffmpeg_path)
26
 
27
+ SECRET_TOKEN = os.getenv('SECRET_TOKEN', 'default_secret')
28
 
 
29
  def do_interpolation(frame1, frame2, times_to_interpolate):
30
  print(frame1, frame2)
31
  input_frames = [frame1, frame2]
 
84
  return type + "_result.mp4"
85
 
86
 
87
+ def infer(secret_token, video_in,interpolation,fps_output):
88
 
89
+ if secret_token != SECRET_TOKEN:
90
+ raise gr.Error(f'Invalid secret token. Please fork the original space if you want to use it for yourself.')
91
 
92
  # 1. break video into frames and get FPS
93
  break_vid = get_frames(video_in, "vid_input_frame", "origin")
 
131
  title="""test space"""
132
 
133
  with gr.Blocks() as demo:
134
+ gr.HTML("""
135
+ <div style="z-index: 100; position: fixed; top: 0px; right: 0px; left: 0px; bottom: 0px; width: 100%; height: 100%; background: white; display: flex; align-items: center; justify-content: center; color: black;">
136
+ <div style="text-align: center; color: black;">
137
+ <p style="color: black;">This space is a REST API to programmatically generate interpolate MP4s.</p>
138
+ </div>
139
+ </div>""")
140
+ secret_token = gr.Textbox(label="Secret token")
141
+ video_input = gr.Video(source="upload", type="filepath")
142
+
143
+ interpolation = gr.Slider(minimum=1,maximum=4,step=1, value=3, label="Interpolation Steps")
144
+ fps_output = gr.Radio([8, 12, 24], label="FPS output", value=24)
145
+ submit_btn = gr.Button("Submit")
146
 
147
+ video_output = gr.Video()
148
+ file_output = gr.File()
 
149
 
150
 
151
+ submit_btn.click(fn=infer, inputs=[secret_token, video_input, interpolation, fps_output], outputs=[video_output, file_output])
152
 
153
  demo.launch()