ClaireOzzz commited on
Commit
f5b7071
1 Parent(s): 1bc4309

Update depthgltf/app_visualisations.py

Browse files
Files changed (1) hide show
  1. depthgltf/app_visualisations.py +25 -12
depthgltf/app_visualisations.py CHANGED
@@ -100,21 +100,34 @@ def create_3d_obj(rgb_image, depth_image, image_path, depth=10):
100
  return gltf_path
101
 
102
 
 
 
103
  title = "Demo: zero-shot depth estimation with DPT + 3D Point Cloud"
104
  description = "This demo is a variation from the original <a href='https://huggingface.co/spaces/nielsr/dpt-depth-estimation' target='_blank'>DPT Demo</a>. It uses the DPT model to predict the depth of an image and then uses 3D Point Cloud to create a 3D object."
105
- # examples = [["examples/" + img] for img in os.listdir("examples/")]
 
 
 
106
 
 
 
 
 
 
 
107
  def create_visual_demo():
108
  iface = gr.Interface(fn=process_image,
109
- inputs=[gr.Image(
110
- type="filepath", label="Input Image")],
111
- outputs=[gr.Image(label="predicted depth", type="pil"),
112
- gr.Model3D(label="3d mesh reconstruction", clear_color=[
113
- 1.0, 1.0, 1.0, 1.0]),
114
- gr.File(label="3d gLTF")],
115
- title=title,
116
- description=description,
117
- # examples=examples,
118
- allow_flagging="never",
119
- cache_examples=False)
 
 
120
  #iface.launch(debug=True, enable_queue=False, share=True)
 
100
  return gltf_path
101
 
102
 
103
+ current_directory = os.path.dirname(__file__)
104
+
105
  title = "Demo: zero-shot depth estimation with DPT + 3D Point Cloud"
106
  description = "This demo is a variation from the original <a href='https://huggingface.co/spaces/nielsr/dpt-depth-estimation' target='_blank'>DPT Demo</a>. It uses the DPT model to predict the depth of an image and then uses 3D Point Cloud to create a 3D object."
107
+ #examples = [["examples/" + img] for img in os.listdir("examples/")]
108
+
109
+ result_image_path = os.path.join(current_directory, '..', 'result.png')
110
+ image_path = Path(result_image_path)
111
 
112
+
113
+ # Load the image
114
+ rawimage = Image.open(image_path)
115
+ image_r = gr.Image(value=rawimage, type="pil", label="Input Image")
116
+ #image_r.change(create_visual_demo, [],[])
117
+
118
  def create_visual_demo():
119
  iface = gr.Interface(fn=process_image,
120
+ inputs=[gr.Image(
121
+ type="filepath", label="Input Image", value=image_path)],
122
+ outputs=[gr.Image(label="predicted depth", type="pil"),
123
+ gr.Model3D(label="3d mesh reconstruction", clear_color=[
124
+ 1.0, 1.0, 1.0, 1.0]),
125
+ gr.File(label="3d gLTF")],
126
+ title=title,
127
+ description=description,
128
+ #examples=examples,
129
+ live=True,
130
+ allow_flagging="never",
131
+ cache_examples=False)
132
+
133
  #iface.launch(debug=True, enable_queue=False, share=True)