Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -77,50 +77,6 @@ def main(share=True):
|
|
| 77 |
metric_depth[~mask] = metric_depth[mask].max()
|
| 78 |
return metric_depth, mask, intrinsics
|
| 79 |
|
| 80 |
-
with gr.Blocks(css=css) as demo:
|
| 81 |
-
gr.Markdown(title)
|
| 82 |
-
gr.Markdown(description)
|
| 83 |
-
gr.Markdown("### Depth Prediction demo")
|
| 84 |
-
|
| 85 |
-
with gr.Row():
|
| 86 |
-
# Left: input image + settings
|
| 87 |
-
with gr.Column():
|
| 88 |
-
input_image = gr.Image(label="Input Image", image_mode="RGB", type='numpy', elem_id='img-display-input')
|
| 89 |
-
with gr.Accordion(label="Settings", open=False):
|
| 90 |
-
denoise_steps = gr.Slider(label="Denoising Steps", minimum=1, maximum=50, value=10, step=1)
|
| 91 |
-
apply_filter = gr.Checkbox(label="Apply filter points", value=True)
|
| 92 |
-
submit_btn = gr.Button(value="Predict Depth")
|
| 93 |
-
|
| 94 |
-
# Right: 3D point cloud + depth
|
| 95 |
-
with gr.Column():
|
| 96 |
-
with gr.Tabs():
|
| 97 |
-
with gr.Tab("3D View"):
|
| 98 |
-
model_3d = gr.Model3D(display_mode="solid", label="3D Point Map", clear_color=[1,1,1,1], height="60vh")
|
| 99 |
-
with gr.Tab("Depth"):
|
| 100 |
-
depth_map = ImageSlider(label="Depth Map with Slider View", elem_id='img-display-output', position=0.5)
|
| 101 |
-
|
| 102 |
-
concat_file = gr.File(label="Concatenated visualization (image+depth)", elem_id="image-depth-download")
|
| 103 |
-
raw_depth_file = gr.File(label="Raw depth output (saved as .npy)", elem_id="download")
|
| 104 |
-
pcd_file = gr.File(label="Point Cloud (.ply)", elem_id="download-ply")
|
| 105 |
-
|
| 106 |
-
submit_btn.click(
|
| 107 |
-
on_submit,
|
| 108 |
-
inputs=[input_image, denoise_steps, apply_filter],
|
| 109 |
-
outputs=[depth_map, model_3d, concat_file, raw_depth_file, pcd_file]
|
| 110 |
-
)
|
| 111 |
-
|
| 112 |
-
example_files = os.listdir('assets/examples')
|
| 113 |
-
example_files.sort()
|
| 114 |
-
example_files = [os.path.join('assets/examples', filename) for filename in example_files]
|
| 115 |
-
examples = gr.Examples(
|
| 116 |
-
examples=example_files,
|
| 117 |
-
inputs=[input_image],
|
| 118 |
-
outputs=[depth_map, model_3d, concat_file, raw_depth_file, pcd_file],
|
| 119 |
-
fn=on_submit
|
| 120 |
-
)
|
| 121 |
-
|
| 122 |
-
demo.queue().launch(share=share)
|
| 123 |
-
|
| 124 |
def on_submit(image, denoise_steps, apply_filter):
|
| 125 |
|
| 126 |
H, W = image.shape[:2]
|
|
@@ -167,6 +123,49 @@ def main(share=True):
|
|
| 167 |
|
| 168 |
return [(image, colored_depth), tmp_ply.name, tmp_concat.name, tmp_raw_depth.name, tmp_ply.name]
|
| 169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
if __name__ == '__main__':
|
| 172 |
main(share=True)
|
|
|
|
| 77 |
metric_depth[~mask] = metric_depth[mask].max()
|
| 78 |
return metric_depth, mask, intrinsics
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
def on_submit(image, denoise_steps, apply_filter):
|
| 81 |
|
| 82 |
H, W = image.shape[:2]
|
|
|
|
| 123 |
|
| 124 |
return [(image, colored_depth), tmp_ply.name, tmp_concat.name, tmp_raw_depth.name, tmp_ply.name]
|
| 125 |
|
| 126 |
+
with gr.Blocks(css=css) as demo:
|
| 127 |
+
gr.Markdown(title)
|
| 128 |
+
gr.Markdown(description)
|
| 129 |
+
gr.Markdown("### Depth Prediction demo")
|
| 130 |
+
|
| 131 |
+
with gr.Row():
|
| 132 |
+
# Left: input image + settings
|
| 133 |
+
with gr.Column():
|
| 134 |
+
input_image = gr.Image(label="Input Image", image_mode="RGB", type='numpy', elem_id='img-display-input')
|
| 135 |
+
with gr.Accordion(label="Settings", open=False):
|
| 136 |
+
denoise_steps = gr.Slider(label="Denoising Steps", minimum=1, maximum=50, value=10, step=1)
|
| 137 |
+
apply_filter = gr.Checkbox(label="Apply filter points", value=True)
|
| 138 |
+
submit_btn = gr.Button(value="Predict Depth")
|
| 139 |
+
|
| 140 |
+
# Right: 3D point cloud + depth
|
| 141 |
+
with gr.Column():
|
| 142 |
+
with gr.Tabs():
|
| 143 |
+
with gr.Tab("3D View"):
|
| 144 |
+
model_3d = gr.Model3D(display_mode="solid", label="3D Point Map", clear_color=[1,1,1,1], height="60vh")
|
| 145 |
+
with gr.Tab("Depth"):
|
| 146 |
+
depth_map = ImageSlider(label="Depth Map with Slider View", elem_id='img-display-output', position=0.5)
|
| 147 |
+
|
| 148 |
+
concat_file = gr.File(label="Concatenated visualization (image+depth)", elem_id="image-depth-download")
|
| 149 |
+
raw_depth_file = gr.File(label="Raw depth output (saved as .npy)", elem_id="download")
|
| 150 |
+
pcd_file = gr.File(label="Point Cloud (.ply)", elem_id="download-ply")
|
| 151 |
+
|
| 152 |
+
submit_btn.click(
|
| 153 |
+
on_submit,
|
| 154 |
+
inputs=[input_image, denoise_steps, apply_filter],
|
| 155 |
+
outputs=[depth_map, model_3d, concat_file, raw_depth_file, pcd_file]
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
example_files = os.listdir('assets/examples')
|
| 159 |
+
example_files.sort()
|
| 160 |
+
example_files = [os.path.join('assets/examples', filename) for filename in example_files]
|
| 161 |
+
examples = gr.Examples(
|
| 162 |
+
examples=example_files,
|
| 163 |
+
inputs=[input_image],
|
| 164 |
+
outputs=[depth_map, model_3d, concat_file, raw_depth_file, pcd_file],
|
| 165 |
+
fn=on_submit
|
| 166 |
+
)
|
| 167 |
+
|
| 168 |
+
demo.queue().launch(share=share)
|
| 169 |
|
| 170 |
if __name__ == '__main__':
|
| 171 |
main(share=True)
|