yeaool commited on
Commit
f00f6a4
1 Parent(s): 693206c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +153 -21
app.py CHANGED
@@ -8,33 +8,165 @@ import tensorflow as tf
8
  from transformers import SegformerFeatureExtractor, TFSegformerForSemanticSegmentation
9
 
10
  feature_extractor = SegformerFeatureExtractor.from_pretrained(
11
- "mattmdjaga/segformer_b2_clothes"
12
  )
13
  model = TFSegformerForSemanticSegmentation.from_pretrained(
14
- "mattmdjaga/segformer_b2_clothes"
15
  )
16
 
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
  ]
39
 
40
  labels_list = []
@@ -103,7 +235,7 @@ def sepia(input_img):
103
  demo = gr.Interface(fn=sepia,
104
  inputs=gr.Image(shape=(400, 600)),
105
  outputs=['plot'],
106
- examples=["person-1.jpg", "person-2.jpg", "person-3.jpg", "person-4.jpg", "person-5.jpg"],
107
  allow_flagging='never')
108
 
109
 
 
8
  from transformers import SegformerFeatureExtractor, TFSegformerForSemanticSegmentation
9
 
10
  feature_extractor = SegformerFeatureExtractor.from_pretrained(
11
+ "nvidia/segformer-b0-finetuned-ade-512-512"
12
  )
13
  model = TFSegformerForSemanticSegmentation.from_pretrained(
14
+ "nvidia/segformer-b0-finetuned-ade-512-512"
15
  )
16
 
17
  def ade_palette():
18
  """ADE20K palette that maps each class to RGB values."""
19
  return [
20
+ [22, 122, 213],
21
+ [240, 3, 156],
22
+ [87, 176, 33],
23
+ [154, 88, 111],
24
+ [63, 54, 244],
25
+ [201, 235, 59],
26
+ [102, 66, 183],
27
+ [94, 147, 5],
28
+ [39, 198, 247],
29
+ [17, 149, 92],
30
+ [130, 78, 184],
31
+ [246, 119, 107],
32
+ [225, 23, 68],
33
+ [52, 189, 140],
34
+ [142, 10, 22],
35
+ [114, 161, 251],
36
+ [168, 55, 34],
37
+ [75, 203, 89],
38
+ [32, 45, 235],
39
+ [217, 134, 0],
40
+ [186, 98, 150],
41
+ [123, 205, 17],
42
+ [58, 29, 192],
43
+ [159, 171, 60],
44
+ [107, 240, 218],
45
+ [4, 80, 124],
46
+ [195, 146, 215],
47
+ [85, 39, 10],
48
+ [137, 112, 160],
49
+ [247, 26, 82],
50
+ [216, 210, 115],
51
+ [48, 135, 229],
52
+ [165, 183, 43],
53
+ [74, 1, 129],
54
+ [31, 166, 96],
55
+ [223, 51, 202],
56
+ [57, 72, 27],
57
+ [143, 191, 176],
58
+ [111, 33, 244],
59
+ [20, 155, 62],
60
+ [128, 99, 209],
61
+ [254, 120, 14],
62
+ [229, 67, 175],
63
+ [53, 206, 40],
64
+ [140, 16, 111],
65
+ [95, 180, 237],
66
+ [38, 58, 152],
67
+ [116, 214, 81],
68
+ [171, 47, 23],
69
+ [209, 36, 178],
70
+ [25, 119, 74],
71
+ [147, 232, 93],
72
+ [61, 153, 255],
73
+ [198, 77, 10],
74
+ [8, 166, 142],
75
+ [133, 45, 111],
76
+ [222, 199, 239],
77
+ [56, 18, 90],
78
+ [164, 98, 206],
79
+ [239, 135, 60],
80
+ [106, 28, 139],
81
+ [49, 172, 224],
82
+ [179, 109, 34],
83
+ [12, 191, 157],
84
+ [121, 64, 88],
85
+ [243, 214, 127],
86
+ [82, 11, 165],
87
+ [158, 37, 192],
88
+ [31, 144, 55],
89
+ [176, 220, 252],
90
+ [68, 5, 123],
91
+ [220, 157, 73],
92
+ [41, 183, 210],
93
+ [173, 85, 14],
94
+ [16, 131, 99],
95
+ [135, 50, 177],
96
+ [227, 202, 244],
97
+ [54, 21, 115],
98
+ [162, 101, 231],
99
+ [236, 138, 49],
100
+ [103, 31, 146],
101
+ [47, 175, 217],
102
+ [181, 112, 28],
103
+ [15, 190, 160],
104
+ [124, 66, 91],
105
+ [241, 217, 130],
106
+ [80, 13, 168],
107
+ [157, 40, 195],
108
+ [30, 147, 52],
109
+ [175, 223, 249],
110
+ [67, 7, 126],
111
+ [218, 160, 76],
112
+ [44, 180, 213],
113
+ [172, 83, 19],
114
+ [19, 129, 102],
115
+ [136, 53, 174],
116
+ [226, 205, 241],
117
+ [52, 24, 118],
118
+ [160, 104, 228],
119
+ [235, 141, 45],
120
+ [101, 33, 149],
121
+ [46, 178, 220],
122
+ [182, 114, 31],
123
+ [14, 193, 163],
124
+ [122, 69, 94],
125
+ [240, 219, 133],
126
+ [79, 16, 171],
127
+ [156, 43, 198],
128
+ [29, 150, 58],
129
+ [174, 225, 246],
130
+ [66, 9, 129],
131
+ [217, 163, 79],
132
+ [43, 182, 216],
133
+ [171, 81, 22],
134
+ [21, 128, 105],
135
+ [137, 56, 176],
136
+ [225, 207, 243],
137
+ [51, 27, 121],
138
+ [159, 107, 229],
139
+ [234, 143, 48],
140
+ [100, 35, 152],
141
+ [45, 176, 223],
142
+ [183, 116, 25],
143
+ [13, 194, 166],
144
+ [123, 71, 97],
145
+ [239, 221, 136],
146
+ [78, 19, 174],
147
+ [155, 46, 201],
148
+ [28, 152, 61],
149
+ [173, 227, 243],
150
+ [65, 11, 132],
151
+ [216, 165, 82],
152
+ [42, 184, 219],
153
+ [170, 78, 24],
154
+ [20, 127, 108],
155
+ [138, 59, 179],
156
+ [224, 209, 245],
157
+ [50, 29, 124],
158
+ [161, 109, 232],
159
+ [233, 145, 51],
160
+ [99, 37, 155],
161
+ [44, 174, 226],
162
+ [184, 118, 20],
163
+ [12, 195, 169],
164
+ [125, 73, 100],
165
+ [238, 223, 139],
166
+ [77, 22, 177],
167
+ [154, 49, 204],
168
+ [27, 154, 64],
169
+ [51, 86, 205]
170
  ]
171
 
172
  labels_list = []
 
235
  demo = gr.Interface(fn=sepia,
236
  inputs=gr.Image(shape=(400, 600)),
237
  outputs=['plot'],
238
+ examples=["testimage1.png"],
239
  allow_flagging='never')
240
 
241