Spaces:
Runtime error
Runtime error
JinHyeong99
commited on
Commit
·
172362f
1
Parent(s):
4bb02ca
README.md
CHANGED
@@ -9,23 +9,4 @@ app_file: app.py
|
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
```python
|
13 |
-
from transformers import SegformerFeatureExtractor, SegformerForSemanticSegmentation
|
14 |
-
from PIL import Image
|
15 |
-
import requests
|
16 |
-
|
17 |
-
feature_extractor = SegformerFeatureExtractor.from_pretrained("nvidia/segformer-b3-finetuned-cityscapes-1024-1024")
|
18 |
-
model = SegformerForSemanticSegmentation.from_pretrained("nvidia/segformer-b3-finetuned-cityscapes-1024-1024")
|
19 |
-
|
20 |
-
url = ["https://imagescdn.gettyimagesbank.com/500/201407/a8281860.jpg",
|
21 |
-
"https://imagescdn.gettyimagesbank.com/500/14/890/614/3/a8281872.jpg",
|
22 |
-
"https://50plus.or.kr/upload/im/2019/06/d3007817-9c63-468d-bbc1-0afa8f10874e.jpg"
|
23 |
-
]
|
24 |
-
image = Image.open(requests.get(url, stream=True).raw)
|
25 |
-
|
26 |
-
inputs = feature_extractor(images=image, return_tensors="pt")
|
27 |
-
outputs = model(**inputs)
|
28 |
-
logits = outputs.logits # shape (batch_size, num_labels, height/4, width/4)
|
29 |
-
```
|
30 |
-
|
31 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
9 |
pinned: false
|
10 |
---
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
import requests
|
4 |
+
|
5 |
+
url1 = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2b2MLoVSTb0tF312bh0HNeFyMPW5w1VV6KZ7yyKw6wx4n7A2uvYaSQkGjsx49yKaKuvU&usqp=CAU"
|
6 |
+
url2 = "https://cdn.bizwnews.com/news/photo/202310/67109_71665_5855.jpg"
|
7 |
+
url3 = "https://wimg.mk.co.kr/news/cms/202306/28/news-p.v1.20230628.118f551f4481418398049c100db5ef16_P1.jpg"
|
8 |
+
|
9 |
+
image1 = Image.open(requests.get(url1, stream=True).raw)
|
10 |
+
image2 = Image.open(requests.get(url2, stream=True).raw)
|
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 |
+
demo.launch()
|