Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,23 +4,23 @@ from transformers import AutoFeatureExtractor, SegformerForSemanticSegmentation
|
|
4 |
import torch
|
5 |
import numpy as np
|
6 |
|
7 |
-
extractor = AutoFeatureExtractor.from_pretrained("
|
8 |
-
model = SegformerForSemanticSegmentation.from_pretrained("hshetty/
|
9 |
def classify(im):
|
10 |
inputs = extractor(images=im, return_tensors="pt")
|
11 |
outputs = model(**inputs)
|
12 |
logits = outputs.logits
|
13 |
classes = logits[0].detach().cpu().numpy().argmax(axis=0)
|
14 |
-
colors = np.array([[128,0,0], [128,128,0], [0, 0, 128],
|
15 |
return colors[classes]
|
16 |
|
17 |
|
18 |
|
19 |
interface = gr.Interface(fn=classify,
|
20 |
-
inputs=
|
21 |
-
outputs=
|
22 |
title="Self Driving Car App- Semantic Segmentation",
|
23 |
-
description="This is a self driving car app using Semantic
|
24 |
examples=["https://datasets-server.huggingface.co/assets/segments/sidewalk-semantic/--/segments--sidewalk-semantic-2/train/3/pixel_values/image.jpg",
|
25 |
"https://datasets-server.huggingface.co/assets/segments/sidewalk-semantic/--/segments--sidewalk-semantic-2/train/5/pixel_values/image.jpg",
|
26 |
"https://datasets-server.huggingface.co/assets/segments/sidewalk-semantic/--/segments--sidewalk-semantic-2/train/20/pixel_values/image.jpg"])
|
|
|
4 |
import torch
|
5 |
import numpy as np
|
6 |
|
7 |
+
extractor = AutoFeatureExtractor.from_pretrained("hshetty/segmentation-model-finetuned-on-semantic-sidewalk-3e-4-e5")
|
8 |
+
model = SegformerForSemanticSegmentation.from_pretrained("hshetty/segmentation-model-finetuned-on-semantic-sidewalk-3e-4-e5")
|
9 |
def classify(im):
|
10 |
inputs = extractor(images=im, return_tensors="pt")
|
11 |
outputs = model(**inputs)
|
12 |
logits = outputs.logits
|
13 |
classes = logits[0].detach().cpu().numpy().argmax(axis=0)
|
14 |
+
colors = np.array([[128,0,0], [128,128,0], [0, 0, 128], [128,0,128], [0, 0, 0]])
|
15 |
return colors[classes]
|
16 |
|
17 |
|
18 |
|
19 |
interface = gr.Interface(fn=classify,
|
20 |
+
inputs="image",
|
21 |
+
outputs="image",
|
22 |
title="Self Driving Car App- Semantic Segmentation",
|
23 |
+
description="This is a self driving car app using Semantic Segmentation as part of week 2 end to end vision application project on CoRise by Abubakar Abid",
|
24 |
examples=["https://datasets-server.huggingface.co/assets/segments/sidewalk-semantic/--/segments--sidewalk-semantic-2/train/3/pixel_values/image.jpg",
|
25 |
"https://datasets-server.huggingface.co/assets/segments/sidewalk-semantic/--/segments--sidewalk-semantic-2/train/5/pixel_values/image.jpg",
|
26 |
"https://datasets-server.huggingface.co/assets/segments/sidewalk-semantic/--/segments--sidewalk-semantic-2/train/20/pixel_values/image.jpg"])
|