depth_compare / app.py
Akash Raj
test
6f72020
raw history blame
No virus
976 Bytes
from transformers import pipeline
from PIL import Image
import gradio as gr
# Load the Hugging Face depth estimation pipeline
pipe = pipeline(task="depth-estimation", model="LiheYoung/depth-anything-small-hf")
def estimate_depth(image):
# Perform depth estimation on the input image
depth = pipe(image)["depth"]
return depth
# Create a Gradio interface
iface = gr.Interface(
fn=estimate_depth,
inputs=gr.Image(type="pil"),
outputs=gr.Image(type="pil"),
title="Depth Estimation",
description="Upload an image to get its depth estimation map."
)
# Launch the Gradio app
iface.launch()
"""
from transformers import pipeline
from PIL import Image
import requests
# load pipe
pipe = pipeline(task="depth-estimation", model="LiheYoung/depth-anything-small-hf")
# load image
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
# inference
depth = pipe(image)["depth"]
"""