Upload 8 files
Browse files- ADE_val_00000001.jpeg +0 -0
- ADE_val_00001159.jpg +0 -0
- ADE_val_00001248.jpg +0 -0
- ADE_val_00001472.jpg +0 -0
- README.md +5 -5
- app.py +136 -138
ADE_val_00000001.jpeg
ADDED
ADE_val_00001159.jpg
ADDED
ADE_val_00001248.jpg
ADDED
ADE_val_00001472.jpg
ADDED
README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
1 |
---
|
2 |
+
title: Segmentation
|
3 |
+
emoji: 👀
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: blue
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 3.44.4
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
app.py
CHANGED
@@ -8,167 +8,165 @@ import tensorflow as tf
|
|
8 |
from transformers import SegformerFeatureExtractor, TFSegformerForSemanticSegmentation
|
9 |
|
10 |
feature_extractor = SegformerFeatureExtractor.from_pretrained(
|
11 |
-
|
12 |
-
"nvidia/segformer-b0-finetuned-ade-512-512"
|
13 |
)
|
14 |
model = TFSegformerForSemanticSegmentation.from_pretrained(
|
15 |
-
|
16 |
-
"nvidia/segformer-b0-finetuned-ade-512-512"
|
17 |
)
|
18 |
|
19 |
def ade_palette():
|
20 |
"""ADE20K palette that maps each class to RGB values."""
|
21 |
return [
|
22 |
-
[
|
23 |
-
[
|
24 |
-
[
|
25 |
-
[
|
26 |
-
[
|
27 |
-
[
|
28 |
-
[
|
29 |
-
[
|
30 |
-
[
|
31 |
-
[
|
32 |
-
[
|
33 |
-
[
|
34 |
-
[
|
35 |
-
[
|
36 |
-
[
|
37 |
-
[
|
38 |
-
[
|
39 |
-
[
|
40 |
-
[
|
41 |
-
[
|
42 |
-
[
|
43 |
-
[
|
44 |
-
[
|
45 |
-
[
|
46 |
-
[
|
47 |
-
[78,
|
48 |
-
[
|
49 |
-
[
|
50 |
-
[
|
51 |
-
[
|
52 |
-
[
|
53 |
-
[
|
54 |
-
[
|
55 |
-
[
|
56 |
-
[
|
57 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
[28, 210, 99],
|
59 |
-
[78,
|
|
|
|
|
|
|
|
|
60 |
[78, 145, 57],
|
61 |
-
[57, 200, 136],
|
62 |
-
[57, 78, 145],
|
63 |
-
[210, 99, 28],
|
64 |
-
[145, 78, 189],
|
65 |
[200, 78, 112],
|
66 |
-
[78, 89, 145],
|
67 |
-
[99, 28, 210],
|
68 |
-
[189, 78, 47],
|
69 |
[99, 89, 145],
|
70 |
-
[78, 145, 57],
|
71 |
[200, 156, 78],
|
72 |
[57, 78, 145],
|
73 |
-
[210, 99, 28],
|
74 |
-
[145, 78, 189],
|
75 |
-
[78, 89, 145],
|
76 |
-
[200, 78, 112],
|
77 |
-
[57, 78, 145],
|
78 |
-
[145, 112, 78],
|
79 |
-
[99, 28, 210],
|
80 |
-
[57, 200, 136],
|
81 |
[78, 57, 99],
|
82 |
-
[28, 210, 99],
|
83 |
-
[189, 78, 47],
|
84 |
-
[145, 78, 189],
|
85 |
-
[78, 57, 99],
|
86 |
-
[99, 28, 210],
|
87 |
-
[57, 200, 136],
|
88 |
-
[145, 112, 78],
|
89 |
-
[78, 89, 145],
|
90 |
-
[200, 78, 112],
|
91 |
-
[78, 57, 99],
|
92 |
-
[99, 28, 210],
|
93 |
-
[145, 78, 99],
|
94 |
-
[28, 210, 99],
|
95 |
-
[145, 112, 78],
|
96 |
-
[78, 89, 145],
|
97 |
-
[57, 200, 136],
|
98 |
[57, 78, 145],
|
99 |
-
[
|
100 |
-
[200, 156, 78],
|
101 |
-
[99, 28, 210],
|
102 |
[78, 89, 145],
|
103 |
-
[145, 78, 189],
|
104 |
-
[57, 78, 145],
|
105 |
-
[200, 78, 112],
|
106 |
-
[78, 57, 99],
|
107 |
-
[99, 89, 145],
|
108 |
[210, 99, 28],
|
109 |
[145, 78, 189],
|
110 |
-
[28, 210, 99],
|
111 |
-
[145, 112, 78],
|
112 |
-
[57, 200, 136],
|
113 |
-
[78, 57, 99],
|
114 |
-
[78, 145, 57],
|
115 |
-
[99, 28, 210],
|
116 |
-
[200, 156, 78],
|
117 |
-
[57, 78, 145],
|
118 |
-
[145, 78, 99],
|
119 |
-
[78, 89, 145],
|
120 |
[57, 200, 136],
|
121 |
-
[
|
122 |
-
[99, 89, 145],
|
123 |
-
[78, 145, 57],
|
124 |
[145, 78, 99],
|
125 |
-
[200, 78, 112],
|
126 |
-
[78, 57, 99],
|
127 |
-
[210, 99, 28],
|
128 |
-
[57, 78, 145],
|
129 |
-
[200, 156, 78],
|
130 |
[99, 28, 210],
|
131 |
[189, 78, 47],
|
132 |
-
[78, 89, 145],
|
133 |
-
[57, 200, 136],
|
134 |
-
[145, 112, 78],
|
135 |
-
[145, 78, 189],
|
136 |
[28, 210, 99],
|
137 |
-
[99, 89, 145],
|
138 |
-
[78, 57, 99],
|
139 |
-
[57, 200, 136],
|
140 |
-
[210, 99, 28],
|
141 |
-
[145, 112, 78],
|
142 |
[78, 145, 57],
|
143 |
-
[78, 89, 145],
|
144 |
-
[57, 78, 145],
|
145 |
-
[200, 78, 112],
|
146 |
-
[189, 78, 47],
|
147 |
-
[200, 156, 78],
|
148 |
-
[57, 200, 136],
|
149 |
-
[99, 89, 145],
|
150 |
-
[99, 28, 210],
|
151 |
-
[145, 112, 78],
|
152 |
-
[145, 78, 99],
|
153 |
-
[57, 78, 145],
|
154 |
-
[28, 210, 99],
|
155 |
-
[78, 57, 99],
|
156 |
-
[78, 145, 57],
|
157 |
-
[57, 200, 136],
|
158 |
-
[78, 89, 145],
|
159 |
-
[99, 28, 210],
|
160 |
-
[200, 156, 78],
|
161 |
-
[145, 78, 189],
|
162 |
-
[78, 57, 99],
|
163 |
-
[57, 78, 145],
|
164 |
-
[210, 99, 28],
|
165 |
-
[99, 89, 145],
|
166 |
-
[28, 210, 99],
|
167 |
-
[145, 112, 78],
|
168 |
-
[200, 78, 112],
|
169 |
-
[78, 57, 99],
|
170 |
-
[57, 78, 145],
|
171 |
-
[99, 28, 210],
|
172 |
]
|
173 |
|
174 |
labels_list = []
|
@@ -237,7 +235,7 @@ def sepia(input_img):
|
|
237 |
demo = gr.Interface(fn=sepia,
|
238 |
inputs=gr.Image(shape=(400, 600)),
|
239 |
outputs=['plot'],
|
240 |
-
examples=["
|
241 |
allow_flagging='never')
|
242 |
|
243 |
|
|
|
8 |
from transformers import SegformerFeatureExtractor, TFSegformerForSemanticSegmentation
|
9 |
|
10 |
feature_extractor = SegformerFeatureExtractor.from_pretrained(
|
11 |
+
"nvidia/segformer-b5-finetuned-ade-640-640"
|
|
|
12 |
)
|
13 |
model = TFSegformerForSemanticSegmentation.from_pretrained(
|
14 |
+
"nvidia/segformer-b5-finetuned-ade-640-640"
|
|
|
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 |
+
[156, 200, 56],
|
39 |
+
[32, 90, 210],
|
40 |
+
[56, 123, 67],
|
41 |
+
[180, 56, 123],
|
42 |
+
[123, 67, 45],
|
43 |
+
[45, 134, 200],
|
44 |
+
[67, 56, 123],
|
45 |
+
[78, 123, 67],
|
46 |
+
[32, 210, 90],
|
47 |
+
[45, 56, 189],
|
48 |
+
[123, 56, 123],
|
49 |
+
[56, 156, 200],
|
50 |
+
[189, 56, 45],
|
51 |
+
[112, 200, 56],
|
52 |
+
[56, 123, 45],
|
53 |
+
[200, 32, 90],
|
54 |
+
[123, 45, 78],
|
55 |
+
[200, 156, 56],
|
56 |
+
[45, 67, 123],
|
57 |
+
[56, 45, 78],
|
58 |
+
[45, 56, 123],
|
59 |
+
[123, 67, 56],
|
60 |
+
[56, 78, 123],
|
61 |
+
[210, 90, 32],
|
62 |
+
[123, 56, 189],
|
63 |
+
[45, 200, 134],
|
64 |
+
[67, 123, 56],
|
65 |
+
[123, 45, 67],
|
66 |
+
[90, 32, 210],
|
67 |
+
[200, 45, 78],
|
68 |
+
[32, 210, 90],
|
69 |
+
[45, 123, 67],
|
70 |
+
[165, 42, 87],
|
71 |
+
[72, 145, 167],
|
72 |
+
[15, 158, 75],
|
73 |
+
[209, 89, 40],
|
74 |
+
[32, 21, 121],
|
75 |
+
[184, 20, 100],
|
76 |
+
[56, 135, 15],
|
77 |
+
[128, 92, 176],
|
78 |
+
[1, 119, 140],
|
79 |
+
[220, 151, 43],
|
80 |
+
[41, 97, 72],
|
81 |
+
[148, 38, 27],
|
82 |
+
[107, 86, 176],
|
83 |
+
[21, 26, 136],
|
84 |
+
[174, 27, 90],
|
85 |
+
[91, 96, 204],
|
86 |
+
[108, 50, 107],
|
87 |
+
[27, 45, 136],
|
88 |
+
[168, 200, 52],
|
89 |
+
[7, 102, 27],
|
90 |
+
[42, 93, 56],
|
91 |
+
[140, 52, 112],
|
92 |
+
[92, 107, 168],
|
93 |
+
[17, 118, 176],
|
94 |
+
[59, 50, 174],
|
95 |
+
[206, 40, 143],
|
96 |
+
[44, 19, 142],
|
97 |
+
[23, 168, 75],
|
98 |
+
[54, 57, 189],
|
99 |
+
[144, 21, 15],
|
100 |
+
[15, 176, 35],
|
101 |
+
[107, 19, 79],
|
102 |
+
[204, 52, 114],
|
103 |
+
[48, 173, 83],
|
104 |
+
[11, 120, 53],
|
105 |
+
[206, 104, 28],
|
106 |
+
[20, 31, 153],
|
107 |
+
[27, 21, 93],
|
108 |
+
[11, 206, 138],
|
109 |
+
[112, 30, 83],
|
110 |
+
[68, 91, 152],
|
111 |
+
[153, 13, 43],
|
112 |
+
[25, 114, 54],
|
113 |
+
[92, 27, 150],
|
114 |
+
[108, 42, 59],
|
115 |
+
[194, 77, 5],
|
116 |
+
[145, 48, 83],
|
117 |
+
[7, 113, 19],
|
118 |
+
[25, 92, 113],
|
119 |
+
[60, 168, 79],
|
120 |
+
[78, 33, 120],
|
121 |
+
[89, 176, 205],
|
122 |
+
[27, 200, 94],
|
123 |
+
[210, 67, 23],
|
124 |
+
[123, 89, 189],
|
125 |
+
[225, 56, 112],
|
126 |
+
[75, 156, 45],
|
127 |
+
[172, 104, 200],
|
128 |
+
[15, 170, 197],
|
129 |
+
[240, 133, 65],
|
130 |
+
[89, 156, 112],
|
131 |
+
[214, 88, 57],
|
132 |
+
[156, 134, 200],
|
133 |
+
[78, 57, 189],
|
134 |
+
[200, 78, 123],
|
135 |
+
[106, 120, 210],
|
136 |
+
[145, 56, 112],
|
137 |
+
[89, 120, 189],
|
138 |
+
[185, 206, 56],
|
139 |
+
[47, 99, 28],
|
140 |
+
[112, 189, 78],
|
141 |
+
[200, 112, 89],
|
142 |
+
[89, 145, 112],
|
143 |
+
[78, 106, 189],
|
144 |
+
[112, 78, 189],
|
145 |
+
[156, 112, 78],
|
146 |
[28, 210, 99],
|
147 |
+
[78, 89, 189],
|
148 |
+
[189, 78, 57],
|
149 |
+
[112, 200, 78],
|
150 |
+
[189, 47, 78],
|
151 |
+
[205, 112, 57],
|
152 |
[78, 145, 57],
|
|
|
|
|
|
|
|
|
153 |
[200, 78, 112],
|
|
|
|
|
|
|
154 |
[99, 89, 145],
|
|
|
155 |
[200, 156, 78],
|
156 |
[57, 78, 145],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
[78, 57, 99],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
[57, 78, 145],
|
159 |
+
[145, 112, 78],
|
|
|
|
|
160 |
[78, 89, 145],
|
|
|
|
|
|
|
|
|
|
|
161 |
[210, 99, 28],
|
162 |
[145, 78, 189],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
[57, 200, 136],
|
164 |
+
[89, 156, 78],
|
|
|
|
|
165 |
[145, 78, 99],
|
|
|
|
|
|
|
|
|
|
|
166 |
[99, 28, 210],
|
167 |
[189, 78, 47],
|
|
|
|
|
|
|
|
|
168 |
[28, 210, 99],
|
|
|
|
|
|
|
|
|
|
|
169 |
[78, 145, 57],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
]
|
171 |
|
172 |
labels_list = []
|
|
|
235 |
demo = gr.Interface(fn=sepia,
|
236 |
inputs=gr.Image(shape=(400, 600)),
|
237 |
outputs=['plot'],
|
238 |
+
examples=["ADE_val_00000001.jpeg", "ADE_val_00001159.jpg", "ADE_val_00001248.jpg", "ADE_val_00001472.jpg"],
|
239 |
allow_flagging='never')
|
240 |
|
241 |
|