Spaces:
Runtime error
Runtime error
JinHyeong99
commited on
Commit
·
0462cba
1
Parent(s):
172362f
app.py
CHANGED
@@ -1,19 +1,13 @@
|
|
1 |
-
import
|
2 |
from PIL import Image
|
3 |
import requests
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
url3 = "https://wimg.mk.co.kr/news/cms/202306/28/news-p.v1.20230628.118f551f4481418398049c100db5ef16_P1.jpg"
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
image3 = Image.open(requests.get(url3, stream=True).raw)
|
12 |
-
demo = gr.Interface(fn=sepia,
|
13 |
-
inputs=gr.Image(shape=(400, 600)),
|
14 |
-
outputs=['plot'],
|
15 |
-
examples=["image1", "image2", "image3"],
|
16 |
-
allow_flagging='never')
|
17 |
|
18 |
-
|
19 |
-
|
|
|
|
1 |
+
from transformers import SegformerFeatureExtractor, SegformerForSemanticSegmentation
|
2 |
from PIL import Image
|
3 |
import requests
|
4 |
|
5 |
+
feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/segformer-b3-finetuned-cityscapes-1024-1024")
|
6 |
+
model = SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b3-finetuned-cityscapes-1024-1024")
|
|
|
7 |
|
8 |
+
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
9 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
inputs = feature_extractor(images=image, return_tensors="pt")
|
12 |
+
outputs = model(**inputs)
|
13 |
+
logits = outputs.logits # shape (batch_size, num_labels, height/4, width/4)
|