DDingcheol commited on
Commit
be8bcb9
·
1 Parent(s): a5fa9cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -25
app.py CHANGED
@@ -1,11 +1,10 @@
1
  import gradio as gr
2
-
3
- from matplotlib import gridspec
4
- import matplotlib.pyplot as plt
5
  import numpy as np
6
- from PIL import Image
7
  import tensorflow as tf
8
- from transformers import SegformerFeatureExtractor, TFSegformerForSemanticSegmentation
 
 
 
9
 
10
  feature_extractor = SegformerFeatureExtractor.from_pretrained(
11
  "nvidia/segformer-b0-finetuned-cityscapes-1024-1024"
@@ -17,25 +16,24 @@ model = TFSegformerForSemanticSegmentation.from_pretrained(
17
  def ade_palette():
18
  """ADE20K palette that maps each class to RGB values."""
19
  return [
20
- [204, 87, 92],
21
- [112, 185, 212],
22
- [45, 189, 106],
23
- [234, 123, 67],
24
- [78, 56, 123],
25
- [210, 32, 89],
26
- [90, 180, 56],
27
- [155, 102, 200],
28
- [33, 147, 176],
29
- [255, 183, 76],
30
- [67, 123, 89],
31
- [190, 60, 45],
32
- [134, 112, 200],
33
- [56, 45, 189],
34
- [200, 56, 123],
35
- [87, 92, 204],
36
- [120, 56, 123],
37
- [45, 78, 123],
38
- [156, 200, 56],
39
  ]
40
 
41
  labels_list = []
@@ -102,7 +100,7 @@ def sepia(input_img):
102
  return fig
103
 
104
  demo = gr.Interface(fn=sepia,
105
- inputs=gr.Image(shape=(400, 600)),
106
  outputs=['plot'],
107
  examples=["citiscapes-1.jpeg", "citiscapes-2.jpeg"],
108
  allow_flagging='never')
 
1
  import gradio as gr
 
 
 
2
  import numpy as np
 
3
  import tensorflow as tf
4
+ from PIL import Image
5
+ from transformers import SegformerImageProcessor, TFSegformerForSemanticSegmentation
6
+ import matplotlib.pyplot as plt
7
+ from matplotlib import gridspec
8
 
9
  feature_extractor = SegformerFeatureExtractor.from_pretrained(
10
  "nvidia/segformer-b0-finetuned-cityscapes-1024-1024"
 
16
  def ade_palette():
17
  """ADE20K palette that maps each class to RGB values."""
18
  return [
19
+ [255, 0, 0],
20
+ [255, 187, 0],
21
+ [255, 228, 0],
22
+ [29, 219, 22],
23
+ [178, 204, 255],
24
+ [1, 0, 255],
25
+ [165, 102, 255],
26
+ [217, 65, 197],
27
+ [116, 116, 116],
28
+ [204, 114, 61],
29
+ [206, 242, 121],
30
+ [61, 183, 204],
31
+ [94, 94, 94],
32
+ [196, 183, 59],
33
+ [246, 246, 246],
34
+ [209, 178, 255],
35
+ [0, 87, 102],
36
+ [153, 0, 76]
 
37
  ]
38
 
39
  labels_list = []
 
100
  return fig
101
 
102
  demo = gr.Interface(fn=sepia,
103
+ inputs=gr.Image(shape=(800, 1200)),
104
  outputs=['plot'],
105
  examples=["citiscapes-1.jpeg", "citiscapes-2.jpeg"],
106
  allow_flagging='never')