pmbrito commited on
Commit
a5fe81c
·
1 Parent(s): 8ed46ca
Files changed (1) hide show
  1. app.py +14 -0
app.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import DPTFeatureExtractor, DPTForSemanticSegmentation
2
+ from PIL import Image
3
+ import requests
4
+
5
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
6
+ image = Image.open(requests.get(url, stream=True).raw)
7
+
8
+ feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-large-ade")
9
+ model = DPTForSemanticSegmentation.from_pretrained("Intel/dpt-large-ade")
10
+
11
+ inputs = feature_extractor(images=image, return_tensors="pt")
12
+
13
+ outputs = model(**inputs)
14
+ logits = outputs.logits