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 = """

Depth Anywhere: Enhancing 360 Monocular Depth Estimation via Perspective Distillation and Unlabeled Data Augmentation

[Project page], [Paper], [Hugging Face Daily Paper]
""" footnote = """
Dominic Alves, https://www.flickr.com/photos/dominicspics/28296671029/, CC BY 2.0 DEED
Luca Biada, https://www.flickr.com/photos/pedroscreamerovsky/6873256488/, CC BY 2.0 DEED
Luca Biada, https://www.flickr.com/photos/pedroscreamerovsky/6798474782/, CC BY 2.0 DEED
""" 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()