File size: 674 Bytes
a5fe81c
 
 
1fefb78
a5fe81c
 
 
703bc1b
a5fe81c
 
 
703bc1b
a5fe81c
 
703bc1b
a5fe81c
 
1fefb78
703bc1b
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from transformers import DPTFeatureExtractor, DPTForSemanticSegmentation
from PIL import Image
import requests
import streamlit as st

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
st.success("Image open: Success")

feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-large-ade")
model = DPTForSemanticSegmentation.from_pretrained("Intel/dpt-large-ade")
st.success("Load model: Success")

inputs = feature_extractor(images=image, return_tensors="pt")
st.success("Feature extraction: Success")

outputs = model(**inputs)
logits = outputs.logits
#st.text(str(logits))
st.success("Success")