Spaces:
Sleeping
Sleeping
app.py
CHANGED
@@ -18,30 +18,30 @@ model = TFSegformerForSemanticSegmentation.from_pretrained(
|
|
18 |
def ade_palette():
|
19 |
"""ADE20K palette that maps each class to RGB values."""
|
20 |
return [
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
]
|
40 |
|
41 |
|
42 |
labels_list = []
|
43 |
|
44 |
-
with open(r
|
45 |
for line in fp:
|
46 |
labels_list.append(line[:-1])
|
47 |
|
@@ -64,7 +64,7 @@ def draw_plot(pred_img, seg):
|
|
64 |
|
65 |
plt.subplot(grid_spec[0])
|
66 |
plt.imshow(pred_img)
|
67 |
-
plt.axis(
|
68 |
LABEL_NAMES = np.asarray(labels_list)
|
69 |
FULL_LABEL_MAP = np.arange(len(LABEL_NAMES)).reshape(len(LABEL_NAMES), 1)
|
70 |
FULL_COLOR_MAP = label_to_color_image(FULL_LABEL_MAP)
|
@@ -106,10 +106,14 @@ def sepia(input_img):
|
|
106 |
return fig
|
107 |
|
108 |
|
109 |
-
demo = gr.Interface(
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
114 |
|
115 |
-
demo.launch()
|
|
|
18 |
def ade_palette():
|
19 |
"""ADE20K palette that maps each class to RGB values."""
|
20 |
return [
|
21 |
+
[255, 0, 0],
|
22 |
+
[0, 255, 0],
|
23 |
+
[0, 0, 255],
|
24 |
+
[255, 255, 0],
|
25 |
+
[0, 255, 255],
|
26 |
+
[255, 0, 255],
|
27 |
+
[128, 0, 0],
|
28 |
+
[0, 128, 0],
|
29 |
+
[0, 0, 128],
|
30 |
+
[128, 128, 0],
|
31 |
+
[0, 128, 128],
|
32 |
+
[128, 0, 128],
|
33 |
+
[192, 192, 192],
|
34 |
+
[128, 128, 128],
|
35 |
+
[255, 128, 0],
|
36 |
+
[255, 0, 128],
|
37 |
+
[0, 255, 128],
|
38 |
+
[128, 255, 0]
|
39 |
]
|
40 |
|
41 |
|
42 |
labels_list = []
|
43 |
|
44 |
+
with open(r"labels.txt", "r") as fp:
|
45 |
for line in fp:
|
46 |
labels_list.append(line[:-1])
|
47 |
|
|
|
64 |
|
65 |
plt.subplot(grid_spec[0])
|
66 |
plt.imshow(pred_img)
|
67 |
+
plt.axis("off")
|
68 |
LABEL_NAMES = np.asarray(labels_list)
|
69 |
FULL_LABEL_MAP = np.arange(len(LABEL_NAMES)).reshape(len(LABEL_NAMES), 1)
|
70 |
FULL_COLOR_MAP = label_to_color_image(FULL_LABEL_MAP)
|
|
|
106 |
return fig
|
107 |
|
108 |
|
109 |
+
demo = gr.Interface(
|
110 |
+
fn=sepia,
|
111 |
+
inputs=gr.Image(shape=(400, 600)),
|
112 |
+
outputs=["plot"],
|
113 |
+
examples=[
|
114 |
+
"person-1.jpg","person-2.jpg","person-3.jpg","person-4.jpg", "person-5.jpg",],
|
115 |
+
allow_flagging="never",
|
116 |
+
)
|
117 |
+
|
118 |
|
119 |
+
demo.launch()
|