File size: 2,133 Bytes
d1ed867 2204800 d1ed867 2204800 d1ed867 8b84b4d bdde79a fae4550 bdde79a a980512 bdde79a a980512 bdde79a d1ed867 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
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()
|