SpyC0der77 commited on
Commit
f64a14d
·
verified ·
1 Parent(s): ddf3277

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -1
app.py CHANGED
@@ -257,4 +257,54 @@ def process_video_ai(
257
  gr.Info("Motion estimated successfully.")
258
 
259
  if auto_zoom:
260
- z = compute_auto_zoom(offsets, out
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  gr.Info("Motion estimated successfully.")
258
 
259
  if auto_zoom:
260
+ z = compute_auto_zoom(offsets, out_w, out_h)
261
+ gr.Info(f"Auto zoom factor computed: {z:.2f}")
262
+ zoom = z
263
+
264
+ stabilized_path = stabilize_stream(
265
+ video_file,
266
+ offsets,
267
+ zoom=float(zoom),
268
+ vertical_only=bool(vertical_only),
269
+ out_w=out_w,
270
+ out_h=out_h,
271
+ progress=progress,
272
+ progress_offset=0.55,
273
+ progress_scale=0.45,
274
+ )
275
+ gr.Info("Video stabilization complete.")
276
+ print("[INFO] Video processing complete.")
277
+
278
+ logs = log_buffer.getvalue()
279
+ return video_file, stabilized_path, logs
280
+
281
+ with gr.Blocks() as demo:
282
+ gr.Markdown("# AI-Powered Video Stabilization")
283
+ gr.Markdown(
284
+ "Upload a video, select a zoom factor (or use Auto Zoom Mode), choose whether to apply only vertical stabilization, and optionally compress the output resolution. "
285
+ "The system estimates motion using RAFT if available (otherwise Farneback) and stabilizes the video with progress updates."
286
+ )
287
+
288
+ with gr.Row():
289
+ with gr.Column():
290
+ video_input = gr.Video(label="Input Video")
291
+ zoom_slider = gr.Slider(minimum=1.0, maximum=3.0, step=0.1, value=1.0, label="Zoom Factor (ignored if Auto Zoom enabled)")
292
+ auto_zoom_checkbox = gr.Checkbox(label="Auto Zoom Mode", value=False)
293
+ vertical_checkbox = gr.Checkbox(label="Vertical Stabilization Only", value=False)
294
+ compress_checkbox = gr.Checkbox(label="Compress Output Resolution", value=False)
295
+ target_width = gr.Number(label="Target Width (px)", value=640)
296
+ target_height = gr.Number(label="Target Height (px)", value=360)
297
+ process_button = gr.Button("Process Video")
298
+ with gr.Column():
299
+ original_video = gr.Video(label="Original Video")
300
+ stabilized_video = gr.Video(label="Stabilized Video")
301
+ logs_output = gr.Textbox(label="Logs", lines=10)
302
+
303
+ process_button.click(
304
+ fn=process_video_ai,
305
+ inputs=[video_input, zoom_slider, vertical_checkbox, compress_checkbox, target_width, target_height, auto_zoom_checkbox],
306
+ outputs=[original_video, stabilized_video, logs_output],
307
+ )
308
+
309
+ if __name__ == "__main__":
310
+ demo.launch()