Insta360-Research commited on
Commit
4018482
·
verified ·
1 Parent(s): a6c65fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -11
app.py CHANGED
@@ -118,17 +118,32 @@ def predict(img_rgb: np.ndarray):
118
  return depth_color_rgb, depth_gray, npy_path
119
 
120
  # ================== Gradio UI ==================
121
- demo = gr.Interface(
122
- fn=predict,
123
- inputs=gr.Image(type="numpy", label="Input Image"),
124
- outputs=[
125
- gr.Image(type="numpy", label="Depth (Color)"),
126
- gr.Image(type="numpy", label="Depth (Gray)"),
127
- gr.File(label="Depth (.npy)"),
128
- ],
129
- title="DAP Depth Prediction Demo",
130
- description="Upload an image and get depth prediction (color / gray / npy).",
131
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
  demo.launch(
134
  server_name="0.0.0.0",
 
118
  return depth_color_rgb, depth_gray, npy_path
119
 
120
  # ================== Gradio UI ==================
121
+ example_paths = [
122
+ "hfdemo/01.jpg",
123
+ "hfdemo/02.jpg",
124
+ "hfdemo/03.jpg",
125
+ "hfdemo/04.jpg",
126
+ "hfdemo/05.jpg",
127
+ "hfdemo/06.jpg",
128
+ ]
129
+
130
+ with gr.Blocks() as demo:
131
+ gr.Markdown("# DAP Depth Prediction Demo\nChoose an example or upload your own image.")
132
+
133
+ inp = gr.Image(type="numpy", label="Input Image")
134
+ out_color = gr.Image(type="numpy", label="Depth (Color)")
135
+ out_gray = gr.Image(type="numpy", label="Depth (Gray)")
136
+ out_npy = gr.File(label="Depth (.npy)")
137
+
138
+ btn = gr.Button("Run")
139
+
140
+ btn.click(fn=predict, inputs=inp, outputs=[out_color, out_gray, out_npy])
141
+
142
+ gr.Examples(
143
+ examples=example_paths,
144
+ inputs=inp,
145
+ label="Examples (click to load)",
146
+ )
147
 
148
  demo.launch(
149
  server_name="0.0.0.0",