Albert-NHWang commited on
Commit
bdde79a
1 Parent(s): 664acf1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -1
app.py CHANGED
@@ -3,5 +3,79 @@ import gradio as gr
3
 
4
 
5
  read_key = os.getenv('HUGGINGFACE_TOKEN')
6
- demo = gr.load("Albert-NHWang/Depth-Anywhere", hf_token=read_key, src="spaces")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  demo.launch()
 
3
 
4
 
5
  read_key = os.getenv('HUGGINGFACE_TOKEN')
6
+ client = Client("Albert-NHWang/Depth-Anywhere", hf_token=read_key)
7
+
8
+
9
+ def get_example():
10
+ case = [
11
+ [
12
+ 'examples/small_nthu_assembly.jpg'
13
+ ],
14
+ [
15
+ 'examples/small_Luca_Biada_flickr_2.jpg'
16
+ ],
17
+ [
18
+ 'examples/small_Dominic_Alves_flickr_panohead_test.jpg'
19
+ ],
20
+ [
21
+ 'examples/small_Luca_Biada_flickr.jpg'
22
+ ],
23
+ ]
24
+ return case
25
+
26
+ def depth(path):
27
+ depth_path = client.predict(handle_file(path), api_name='/process_image')
28
+ return depth_path
29
+
30
+ intro = """
31
+ <div style="text-align:center">
32
+ <h1 style="font-weight: 1400; text-align: center; margin-bottom: 7px;">
33
+ Depth Anywhere: Enhancing 360 Monocular Depth Estimation via Perspective Distillation and Unlabeled Data Augmentation
34
+ </h1>
35
+ <span>[<a target="_blank" href="https://albert100121.github.io/Depth-Anywhere/">Project page</a>], [<a target="_blank" href="http://arxiv.org/abs/2406.12849">Paper</a>], [<a target="_blank" href="https://huggingface.co/papers/2406.12849">Hugging Face Daily Paper</a>]</span>
36
+ <div style="display:flex; justify-content: center;margin-top: 0.5em">Please test with browsers other then Safari, and avoid using incognito window due to unsolved gradio bug!</div>
37
+ </div>
38
+ """
39
+ footnote = """
40
+ <div style="display:flex; justify-content: left;margin-top: 0.5em">
41
+ Dominic Alves, https://www.flickr.com/photos/dominicspics/28296671029/, CC BY 2.0 DEED <br>
42
+ Luca Biada, https://www.flickr.com/photos/pedroscreamerovsky/6873256488/, CC BY 2.0 DEED <br>
43
+ Luca Biada, https://www.flickr.com/photos/pedroscreamerovsky/6798474782/, CC BY 2.0 DEED</div>
44
+ """
45
+
46
+
47
+ with gr.Blocks() as demo:
48
+ gr.HTML(intro)
49
+ with gr.Row():
50
+ input_image = gr.File(type="filepath")
51
+ output_rgb = gr.Image(label="Loaded Image", type="filepath")
52
+ with gr.Row():
53
+ load_button = gr.Button("Load RGB!", visible=True)
54
+
55
+ load_button.click(fn = lambda x: x,
56
+ inputs = [input_image],
57
+ outputs = [output_rgb]
58
+ )
59
+
60
+ with gr.Row():
61
+ output_image = gr.Image(label="Output Depth", type="filepath")
62
+
63
+ with gr.Row():
64
+ run_button = gr.Button("Estimate Depth!", visible=True)
65
+
66
+ run_button.click(fn = depth,
67
+ inputs = [input_image],
68
+ outputs = [output_image]
69
+ )
70
+
71
+ gr.Examples(
72
+ fn=lambda x:x,
73
+ inputs=[input_image],
74
+ outputs=[output_rgb],
75
+ examples=get_example(),
76
+ run_on_click=True,
77
+ cache_examples=False)
78
+
79
+ gr.HTML(footnote)
80
+ demo.queue()
81
  demo.launch()