hshetty commited on
Commit
52b7465
1 Parent(s): 3a1ab6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
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("nvidia/segformer-b0-finetuned-ade-512-512")
8
- model = SegformerForSemanticSegmentation.from_pretrained("hshetty/my-segmentation-model")
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=gr.inputs.Image(type="pil"),
21
- outputs=gr.inputs.Image(type="pil"),
22
  title="Self Driving Car App- Semantic Segmentation",
23
- description="This is a self driving car app using Semantic Semendation as part of week 2 end to end vision application project on CoRise.",
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"])