Spaces:
Running
Running
File size: 1,516 Bytes
6f72020 7e9d2f3 516f50c 7e9d2f3 1d0844e 516f50c 1d0844e 516f50c bb518d4 516f50c 1d0844e |
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 |
from transformers import pipeline
from PIL import Image
import gradio as gr
# Load the Hugging Face depth estimation pipelines
pipe_base = pipeline(task="depth-estimation", model="LiheYoung/depth-anything-base-hf")
pipe_small = pipeline(task="depth-estimation", model="LiheYoung/depth-anything-small-hf")
pipe_intel = pipeline(task="depth-estimation", model="Intel/dpt-swinv2-tiny-256")
def estimate_depths(image):
# Perform depth estimation with each pipeline
depth_base = pipe_base(image)["depth"]
depth_small = pipe_small(image)["depth"]
depth_intel = pipe_intel(image)["depth"]
return depth_base, depth_small, depth_intel
# Create a Gradio interface
iface = gr.Interface(
fn=estimate_depths,
inputs=gr.Image(type="pil"),
outputs=[
gr.Image(type="pil", label="LiheYoung/depth-anything-base-hf"),
gr.Image(type="pil", label="LiheYoung/depth-anything-small-hf"),
gr.Image(type="pil", label="Intel/dpt-swinv2-tiny-256")
],
title="Multi-Model Depth Estimation",
description="Upload an image to get depth estimation maps from multiple models."
)
# 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"]
""" |