Spaces:
Runtime error
Runtime error
haotongl
commited on
Commit
·
439c90f
1
Parent(s):
141f1e8
inital version
Browse files
app.py
CHANGED
|
@@ -13,9 +13,8 @@ import gradio as gr
|
|
| 13 |
from gradio_imageslider import ImageSlider
|
| 14 |
import cv2
|
| 15 |
import numpy as np
|
| 16 |
-
import click
|
| 17 |
import imageio
|
| 18 |
-
from promptda.promptda import PromptDA
|
| 19 |
from promptda.utils.io_wrapper import load_image, load_depth
|
| 20 |
from promptda.utils.depth_utils import visualize_depth, unproject_depth
|
| 21 |
# import torch
|
|
@@ -23,7 +22,7 @@ DEVICE = 'cuda'
|
|
| 23 |
# if torch.cuda.is_available(
|
| 24 |
# ) else 'mps' if torch.backends.mps.is_available() else 'cpu'
|
| 25 |
# model = PromptDA.from_pretrained('depth-anything/promptda_vitl').to(DEVICE).eval()
|
| 26 |
-
model = PromptDA.from_pretrained('depth-anything/promptda_vitl').eval()
|
| 27 |
thread_pool_executor = ThreadPoolExecutor(max_workers=1)
|
| 28 |
|
| 29 |
def delete_later(path: Union[str, os.PathLike], delay: int = 300):
|
|
@@ -144,76 +143,76 @@ Note:
|
|
| 144 |
|
| 145 |
# @click.command()
|
| 146 |
# @click.option('--share', is_flag=True, help='Whether to run the app in shared mode.')
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
|
| 156 |
-
#
|
| 157 |
-
#
|
| 158 |
-
#
|
| 159 |
-
#
|
| 160 |
-
#
|
| 161 |
-
#
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
# ]
|
| 182 |
-
# gr.Examples(examples=[
|
| 183 |
-
# ["data/assets/example0_chair.zip", "756x1008"]
|
| 184 |
-
# ],
|
| 185 |
-
# fn=run,
|
| 186 |
-
# inputs=[input_file, resolution],
|
| 187 |
-
# outputs=outputs,
|
| 188 |
-
# label="Examples",
|
| 189 |
-
# cache_examples=True,
|
| 190 |
-
# )
|
| 191 |
-
# submit_btn.click(run,
|
| 192 |
-
# inputs=[input_file, resolution],
|
| 193 |
-
# outputs=outputs)
|
| 194 |
-
|
| 195 |
-
# demo.launch()
|
| 196 |
-
def main():
|
| 197 |
-
gr.Interface(
|
| 198 |
-
fn=run,
|
| 199 |
-
inputs=[
|
| 200 |
-
gr.File(type="filepath", label="Stray scanner app capture zip file"),
|
| 201 |
-
gr.Dropdown(choices=['756x1008', '1428x1904'], value='756x1008', label="Inference resolution")
|
| 202 |
-
],
|
| 203 |
-
outputs=[
|
| 204 |
-
gr.Image(type="numpy", label="RGB Image"),
|
| 205 |
-
ImageSlider(label="Depth map / prompt depth", position=0.5),
|
| 206 |
-
gr.Model3D(label="3D Viewer", display_mode='solid', clear_color=[1.0, 1.0, 1.0, 1.0]),
|
| 207 |
-
gr.File(type="filepath", label="Download the unprojected point cloud as .ply file"),
|
| 208 |
-
gr.File(type="filepath", label="Download the depth map as .png file"),
|
| 209 |
-
],
|
| 210 |
-
title=None,
|
| 211 |
-
description=DESCRIPTION,
|
| 212 |
-
clear_btn=None,
|
| 213 |
-
allow_flagging="never",
|
| 214 |
-
theme=gr.themes.Soft(),
|
| 215 |
-
examples=[
|
| 216 |
-
["data/assets/example0_chair.zip"]
|
| 217 |
]
|
| 218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
main()
|
|
|
|
| 13 |
from gradio_imageslider import ImageSlider
|
| 14 |
import cv2
|
| 15 |
import numpy as np
|
|
|
|
| 16 |
import imageio
|
| 17 |
+
# from promptda.promptda import PromptDA
|
| 18 |
from promptda.utils.io_wrapper import load_image, load_depth
|
| 19 |
from promptda.utils.depth_utils import visualize_depth, unproject_depth
|
| 20 |
# import torch
|
|
|
|
| 22 |
# if torch.cuda.is_available(
|
| 23 |
# ) else 'mps' if torch.backends.mps.is_available() else 'cpu'
|
| 24 |
# model = PromptDA.from_pretrained('depth-anything/promptda_vitl').to(DEVICE).eval()
|
| 25 |
+
# model = PromptDA.from_pretrained('depth-anything/promptda_vitl').eval()
|
| 26 |
thread_pool_executor = ThreadPoolExecutor(max_workers=1)
|
| 27 |
|
| 28 |
def delete_later(path: Union[str, os.PathLike], delay: int = 300):
|
|
|
|
| 143 |
|
| 144 |
# @click.command()
|
| 145 |
# @click.option('--share', is_flag=True, help='Whether to run the app in shared mode.')
|
| 146 |
+
def main():
|
| 147 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 148 |
+
gr.Markdown(DESCRIPTION)
|
| 149 |
|
| 150 |
+
with gr.Row():
|
| 151 |
+
input_file = gr.File(type="filepath", label="Stray scanner app capture zip file")
|
| 152 |
+
resolution = gr.Dropdown(choices=['756x1008', '1428x1904'], value='756x1008', label="Inference resolution")
|
| 153 |
+
submit_btn = gr.Button("Submit")
|
| 154 |
|
| 155 |
+
# gr.Examples(examples=[
|
| 156 |
+
# ["data/assets/example0_chair.zip", "756x1008"]
|
| 157 |
+
# ],
|
| 158 |
+
# inputs=[input_file, resolution],
|
| 159 |
+
# label="Examples",
|
| 160 |
+
# )
|
| 161 |
+
|
| 162 |
+
with gr.Row():
|
| 163 |
+
with gr.Column():
|
| 164 |
+
output_rgb = gr.Image(type="numpy", label="RGB Image")
|
| 165 |
+
with gr.Column():
|
| 166 |
+
output_depths = ImageSlider(label="Output depth / prompt depth", position=0.5)
|
| 167 |
|
| 168 |
+
with gr.Row():
|
| 169 |
+
with gr.Column():
|
| 170 |
+
output_3d_model = gr.Model3D(label="3D Viewer", display_mode='solid', clear_color=[1.0, 1.0, 1.0, 1.0])
|
| 171 |
+
with gr.Column():
|
| 172 |
+
output_ply = gr.File(type="filepath", label="Download the unprojected point cloud as .ply file", height=30)
|
| 173 |
+
output_depth_map = gr.File(type="filepath", label="Download the depth map as .png file", height=30)
|
| 174 |
+
outputs = [
|
| 175 |
+
output_rgb,
|
| 176 |
+
output_depths,
|
| 177 |
+
output_3d_model,
|
| 178 |
+
output_ply,
|
| 179 |
+
output_depth_map,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
]
|
| 181 |
+
gr.Examples(examples=[
|
| 182 |
+
["data/assets/example0_chair.zip", "756x1008"]
|
| 183 |
+
],
|
| 184 |
+
fn=run,
|
| 185 |
+
inputs=[input_file, resolution],
|
| 186 |
+
outputs=outputs,
|
| 187 |
+
label="Examples",
|
| 188 |
+
cache_examples=True,
|
| 189 |
+
)
|
| 190 |
+
submit_btn.click(run,
|
| 191 |
+
inputs=[input_file, resolution],
|
| 192 |
+
outputs=outputs)
|
| 193 |
+
|
| 194 |
+
demo.launch()
|
| 195 |
+
# def main():
|
| 196 |
+
# gr.Interface(
|
| 197 |
+
# fn=run,
|
| 198 |
+
# inputs=[
|
| 199 |
+
# gr.File(type="filepath", label="Stray scanner app capture zip file"),
|
| 200 |
+
# gr.Dropdown(choices=['756x1008', '1428x1904'], value='756x1008', label="Inference resolution")
|
| 201 |
+
# ],
|
| 202 |
+
# outputs=[
|
| 203 |
+
# gr.Image(type="numpy", label="RGB Image"),
|
| 204 |
+
# ImageSlider(label="Depth map / prompt depth", position=0.5),
|
| 205 |
+
# gr.Model3D(label="3D Viewer", display_mode='solid', clear_color=[1.0, 1.0, 1.0, 1.0]),
|
| 206 |
+
# gr.File(type="filepath", label="Download the unprojected point cloud as .ply file"),
|
| 207 |
+
# gr.File(type="filepath", label="Download the depth map as .png file"),
|
| 208 |
+
# ],
|
| 209 |
+
# title=None,
|
| 210 |
+
# description=DESCRIPTION,
|
| 211 |
+
# clear_btn=None,
|
| 212 |
+
# allow_flagging="never",
|
| 213 |
+
# theme=gr.themes.Soft(),
|
| 214 |
+
# examples=[
|
| 215 |
+
# ["data/assets/example0_chair.zip"]
|
| 216 |
+
# ]
|
| 217 |
+
# ).launch()
|
| 218 |
main()
|