merve HF staff commited on
Commit
3691ba9
1 Parent(s): d643ca3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -13,19 +13,19 @@ dpt_beit = pipeline(task = "depth-estimation", model="Intel/dpt-beit-base-384")
13
  depth_anything = pipeline(task = "depth-estimation", model="nielsr/depth-anything-small")
14
  dpt_large = pipeline(task = "depth-estimation", model="intel/dpt-large")
15
  @spaces.GPU
16
- def depth_anything_inference(image_path):
17
- return depth_anything(image_path)["depth"]
18
  @spaces.GPU
19
- def dpt_beit_inference(image):
20
- return dpt_beit(image)["depth"]
21
 
22
  @spaces.GPU
23
- def dpt_large_inference(image):
24
- return dpt_large(image)["depth"]
25
 
26
 
27
- def infer(image):
28
- return dpt_large_inference(image), dpt_beit_inference(image), depth_anything_inference(image)
29
 
30
 
31
  css = """
@@ -39,12 +39,19 @@ with gr.Blocks(css=css) as demo:
39
  gr.HTML("<h1><center>Compare Depth Estimation Models<center><h1>")
40
  with gr.Column():
41
  with gr.Row():
42
- input_img = gr.Image(label="Input Image")
43
  with gr.Row():
44
  output_1 = gr.Image(type="pil", label="DPT-Large")
45
  output_2 = gr.Image(type="pil", label="DPT with BeiT Backbone")
46
  output_3 = gr.Image(type="pil", label="Depth Anything")
47
-
 
 
 
 
 
 
 
48
 
49
  input_img.change(infer, [input_img], [output_1, output_2, output_3])
50
 
 
13
  depth_anything = pipeline(task = "depth-estimation", model="nielsr/depth-anything-small")
14
  dpt_large = pipeline(task = "depth-estimation", model="intel/dpt-large")
15
  @spaces.GPU
16
+ def depth_anything_inference(img):
17
+ return depth_anything(img)["depth"]
18
  @spaces.GPU
19
+ def dpt_beit_inference(img):
20
+ return dpt_beit(img)["depth"]
21
 
22
  @spaces.GPU
23
+ def dpt_large_inference(img):
24
+ return dpt_large(img)["depth"]
25
 
26
 
27
+ def infer(img):
28
+ return dpt_large_inference(img), dpt_beit_inference(img), depth_anything_inference(img)
29
 
30
 
31
  css = """
 
39
  gr.HTML("<h1><center>Compare Depth Estimation Models<center><h1>")
40
  with gr.Column():
41
  with gr.Row():
42
+ input_img = gr.Image(label="Input Image", type="pil")
43
  with gr.Row():
44
  output_1 = gr.Image(type="pil", label="DPT-Large")
45
  output_2 = gr.Image(type="pil", label="DPT with BeiT Backbone")
46
  output_3 = gr.Image(type="pil", label="Depth Anything")
47
+
48
+ gr.Examples([["bee.jpg"]],
49
+ inputs = input_img,
50
+ outputs = [output_1, output_2, output_3],
51
+ fn=infer,
52
+ cache_examples=True,
53
+ label='Click on any Examples below to get depth estimation results quickly 👇'
54
+ )
55
 
56
  input_img.change(infer, [input_img], [output_1, output_2, output_3])
57