Spaces:
Sleeping
Sleeping
Commit
·
be8bcb9
1
Parent(s):
a5fa9cc
Update app.py
Browse files
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
|
|
|
|
|
|
|
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 |
-
[
|
21 |
-
[
|
22 |
-
[
|
23 |
-
[
|
24 |
-
[
|
25 |
-
[
|
26 |
-
[
|
27 |
-
[
|
28 |
-
[
|
29 |
-
[
|
30 |
-
[
|
31 |
-
[
|
32 |
-
[
|
33 |
-
[
|
34 |
-
[
|
35 |
-
[
|
36 |
-
[
|
37 |
-
[
|
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=(
|
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')
|