Albert-NHWang's picture
Update app.py
a980512 verified
raw
history blame
2.13 kB
import os
import cv2
import gradio as gr
from gradio_client import Client, handle_file
read_key = os.getenv('HUGGINGFACE_TOKEN')
client = Client("Albert-NHWang/Depth-Anywhere", hf_token=read_key)
def get_example():
case = [
[
'examples/small_nthu_assembly.jpg'
],
[
'examples/small_Luca_Biada_flickr_2.jpg'
],
[
'examples/small_Dominic_Alves_flickr_panohead_test.jpg'
],
[
'examples/small_Luca_Biada_flickr.jpg'
],
]
return case
def depth(path):
depth_path = client.predict(handle_file(path), api_name='/process_image')
return depth_path
intro = """
<div style="text-align:center">
<h1 style="font-weight: 1400; text-align: center; margin-bottom: 7px;">
Depth Anywhere: Enhancing 360 Monocular Depth Estimation via Perspective Distillation and Unlabeled Data Augmentation
</h1>
<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>
</div>
"""
footnote = """
<div style="display:flex; justify-content: left;margin-top: 0.5em">
Dominic Alves, https://www.flickr.com/photos/dominicspics/28296671029/, CC BY 2.0 DEED <br>
Luca Biada, https://www.flickr.com/photos/pedroscreamerovsky/6873256488/, CC BY 2.0 DEED <br>
Luca Biada, https://www.flickr.com/photos/pedroscreamerovsky/6798474782/, CC BY 2.0 DEED</div>
"""
with gr.Blocks(css="style.css") as demo:
gr.HTML(intro)
with gr.Row():
input_image = gr.Image(type="filepath")
output_image = gr.Image(label="Output Depth", type="filepath")
with gr.Row():
run_button = gr.Button("Estimate Depth!", visible=True)
run_button.click(fn = depth,
inputs = [input_image],
outputs = [output_image]
)
gr.Examples(
inputs=[input_image],
examples=get_example(),
cache_examples=False)
gr.HTML(footnote)
demo.queue()
demo.launch()