import gradio as gr | |
from transformers import pipeline | |
from PIL import Image | |
import requests | |
def greet(name): | |
# 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"] | |
return name+": " + depth | |
iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
iface.launch() |