Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,6 +17,7 @@ Please refer to our [paper](https://arxiv.org/abs/2501.12375), [project page](ht
|
|
| 17 |
def stitch_rgbd_videos(
|
| 18 |
processed_video: str,
|
| 19 |
depth_vis_video: str,
|
|
|
|
| 20 |
max_len: int = -1,
|
| 21 |
target_fps: int = -1,
|
| 22 |
max_res: int = 1280,
|
|
@@ -37,6 +38,7 @@ def stitch_rgbd_videos(
|
|
| 37 |
full_frames, target_fps = read_video_frames(processed_video, max_len, target_fps, max_res=-1)
|
| 38 |
depths, _ = read_video_frames(depth_vis_video, max_len, target_fps, max_res=-1)
|
| 39 |
|
|
|
|
| 40 |
# For each frame, create a visual depth image from the inferenced depths.
|
| 41 |
d_min, d_max = depths.min(), depths.max()
|
| 42 |
stitched_frames = []
|
|
@@ -120,7 +122,7 @@ def stitch_rgbd_videos(
|
|
| 120 |
"ffmpeg",
|
| 121 |
"-y",
|
| 122 |
"-i", stitched_video_path,
|
| 123 |
-
"-i",
|
| 124 |
"-c:v", "copy",
|
| 125 |
"-c:a", "aac",
|
| 126 |
"-map", "0:v:0",
|
|
@@ -144,7 +146,9 @@ def construct_demo():
|
|
| 144 |
with gr.Column(scale=1):
|
| 145 |
# Video input component for file upload.
|
| 146 |
processed_video = gr.Video(label="Input Video")
|
| 147 |
-
depth_vis_video = gr.Video(label="
|
|
|
|
|
|
|
| 148 |
with gr.Column(scale=2):
|
| 149 |
with gr.Row(equal_height=True):
|
| 150 |
stitched_video = gr.Video(label="Stitched RGBD Video", interactive=False, autoplay=True, loop=True, show_share_button=True, scale=5)
|
|
@@ -154,7 +158,7 @@ def construct_demo():
|
|
| 154 |
with gr.Accordion("Advanced Settings", open=False):
|
| 155 |
max_len = gr.Slider(label="Max process length", minimum=-1, maximum=1000, value=-1, step=1)
|
| 156 |
target_fps = gr.Slider(label="Target FPS", minimum=-1, maximum=30, value=-1, step=1)
|
| 157 |
-
max_res = gr.Slider(label="Max side resolution", minimum=480, maximum=1920, value=
|
| 158 |
stitch_option = gr.Checkbox(label="Stitch RGB & Depth Videos", value=True)
|
| 159 |
grayscale_option = gr.Checkbox(label="Output Depth as Grayscale", value=True)
|
| 160 |
convert_from_color_option = gr.Checkbox(label="Convert Grayscale from Color", value=True)
|
|
@@ -165,7 +169,7 @@ def construct_demo():
|
|
| 165 |
|
| 166 |
generate_btn.click(
|
| 167 |
fn=stitch_rgbd_videos,
|
| 168 |
-
inputs=[processed_video, depth_vis_video, max_len, target_fps, max_res, stitch_option, grayscale_option, convert_from_color_option, blur_slider],
|
| 169 |
outputs=stitched_video,
|
| 170 |
)
|
| 171 |
|
|
@@ -173,4 +177,4 @@ def construct_demo():
|
|
| 173 |
|
| 174 |
if __name__ == "__main__":
|
| 175 |
demo = construct_demo()
|
| 176 |
-
demo.queue(max_size=
|
|
|
|
| 17 |
def stitch_rgbd_videos(
|
| 18 |
processed_video: str,
|
| 19 |
depth_vis_video: str,
|
| 20 |
+
audio_video: str,
|
| 21 |
max_len: int = -1,
|
| 22 |
target_fps: int = -1,
|
| 23 |
max_res: int = 1280,
|
|
|
|
| 38 |
full_frames, target_fps = read_video_frames(processed_video, max_len, target_fps, max_res=-1)
|
| 39 |
depths, _ = read_video_frames(depth_vis_video, max_len, target_fps, max_res=-1)
|
| 40 |
|
| 41 |
+
|
| 42 |
# For each frame, create a visual depth image from the inferenced depths.
|
| 43 |
d_min, d_max = depths.min(), depths.max()
|
| 44 |
stitched_frames = []
|
|
|
|
| 122 |
"ffmpeg",
|
| 123 |
"-y",
|
| 124 |
"-i", stitched_video_path,
|
| 125 |
+
"-i", audio_video,
|
| 126 |
"-c:v", "copy",
|
| 127 |
"-c:a", "aac",
|
| 128 |
"-map", "0:v:0",
|
|
|
|
| 146 |
with gr.Column(scale=1):
|
| 147 |
# Video input component for file upload.
|
| 148 |
processed_video = gr.Video(label="Input Video")
|
| 149 |
+
depth_vis_video = gr.Video(label="Depth Video")
|
| 150 |
+
with gr.Column(scale=1):
|
| 151 |
+
audio_video = gr.Video(label="Audio Source")
|
| 152 |
with gr.Column(scale=2):
|
| 153 |
with gr.Row(equal_height=True):
|
| 154 |
stitched_video = gr.Video(label="Stitched RGBD Video", interactive=False, autoplay=True, loop=True, show_share_button=True, scale=5)
|
|
|
|
| 158 |
with gr.Accordion("Advanced Settings", open=False):
|
| 159 |
max_len = gr.Slider(label="Max process length", minimum=-1, maximum=1000, value=-1, step=1)
|
| 160 |
target_fps = gr.Slider(label="Target FPS", minimum=-1, maximum=30, value=-1, step=1)
|
| 161 |
+
max_res = gr.Slider(label="Max side resolution", minimum=480, maximum=1920, value=1920, step=1)
|
| 162 |
stitch_option = gr.Checkbox(label="Stitch RGB & Depth Videos", value=True)
|
| 163 |
grayscale_option = gr.Checkbox(label="Output Depth as Grayscale", value=True)
|
| 164 |
convert_from_color_option = gr.Checkbox(label="Convert Grayscale from Color", value=True)
|
|
|
|
| 169 |
|
| 170 |
generate_btn.click(
|
| 171 |
fn=stitch_rgbd_videos,
|
| 172 |
+
inputs=[processed_video, depth_vis_video, audio_video, max_len, target_fps, max_res, stitch_option, grayscale_option, convert_from_color_option, blur_slider],
|
| 173 |
outputs=stitched_video,
|
| 174 |
)
|
| 175 |
|
|
|
|
| 177 |
|
| 178 |
if __name__ == "__main__":
|
| 179 |
demo = construct_demo()
|
| 180 |
+
demo.queue(max_size=4).launch()
|