File size: 529 Bytes
9e00705
4dd7449
5a34e37
318bdb2
 
9e00705
 
4dd7449
5a34e37
 
4dd7449
5a34e37
 
1b9d457
4dd7449
5a34e37
 
d4d3c51
9e00705
 
91c84b6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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()