fffiloni commited on
Commit
d275034
·
1 Parent(s): 8799216

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -13
app.py CHANGED
@@ -173,18 +173,30 @@ def infer(frameA, frameB):
173
 
174
  return "predicted_flow.jpg", ["flofile.flo"]
175
 
 
176
  description="<p style='text-align:center'>PyTorch way to Generate optical flow image & .flo file from 2 consecutive frames with RAFT model</p>"
177
 
178
- gr.Interface(fn=infer,
179
- inputs=[
180
- gr.Image(source="upload", type="filepath", label="frame 1"),
181
- gr.Image(source="upload", type="filepath", label="frame 2")],
182
- outputs=[
183
- gr.Image(label="flow image"),
184
- gr.Files(label="flow file")],
185
- title="RAFT Optical Flow",
186
- description=description,
187
- examples=[
188
- ["examples/basket1.JPG", "examples/basket2.JPG"]
189
- ]
190
- ).launch()
 
 
 
 
 
 
 
 
 
 
 
 
173
 
174
  return "predicted_flow.jpg", ["flofile.flo"]
175
 
176
+ title="RAFT Optical Flow"
177
  description="<p style='text-align:center'>PyTorch way to Generate optical flow image & .flo file from 2 consecutive frames with RAFT model</p>"
178
 
179
+ with gr.Blocks() as block:
180
+ with gr.Column(elem_id="col-container"):
181
+ gr.HTML(title)
182
+ gr.HTML(description)
183
+
184
+ frame1_inp = gr.Image(source="upload", type="filepath", label="frame 1")
185
+ frame2_inp = gr.Image(source="upload", type="filepath", label="frame 2")]
186
+
187
+ submit_btn = gr.Button("Submit")
188
+
189
+ flow_img_out = gr.Image(label="flow image")
190
+ flow_file_out = gr.Files(label="flow file")]
191
+
192
+
193
+ examples=[['basket1.jpg'], ['basket2.jpg']]
194
+ ex = gr.Examples(examples=examples, fn=infer, inputs=[frame1_inp, frame2_inp], outputs=[flow_img_out, flow_file_out], cache_examples=True, run_on_click=True)
195
+ ex.dataset.headers = [""]
196
+
197
+
198
+
199
+ submit_btn.click(fn=infer, inputs=[frame1_inp, frame2_inp], outputs=[flow_img_out, flow_file_out])
200
+
201
+
202
+ block.launch()