Spaces:
Sleeping
Sleeping
GoBoKyung
commited on
Commit
โข
074b669
1
Parent(s):
abbed59
city
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ model = TFSegformerForSemanticSegmentation.from_pretrained(
|
|
15 |
)
|
16 |
|
17 |
def ade_palette():
|
18 |
-
"""ADE20K
|
19 |
return [
|
20 |
[204, 87, 92],
|
21 |
[112, 185, 212],
|
@@ -48,10 +48,10 @@ colormap = np.asarray(ade_palette())
|
|
48 |
|
49 |
def label_to_color_image(label):
|
50 |
if label.ndim != 2:
|
51 |
-
raise ValueError("
|
52 |
|
53 |
if np.max(label) >= len(colormap):
|
54 |
-
raise ValueError("
|
55 |
return colormap[label]
|
56 |
|
57 |
def draw_plot(pred_img, seg):
|
@@ -76,11 +76,11 @@ def draw_plot(pred_img, seg):
|
|
76 |
return fig
|
77 |
|
78 |
def sepia(input_text):
|
79 |
-
#
|
80 |
if not os.path.isfile(input_text):
|
81 |
-
return "
|
82 |
|
83 |
-
#
|
84 |
input_img = Image.open(input_text)
|
85 |
|
86 |
inputs = feature_extractor(images=input_img, return_tensors="tf")
|
@@ -102,13 +102,13 @@ def sepia(input_text):
|
|
102 |
pred_img = np.array(input_img) * 0.5 + color_seg * 0.5
|
103 |
pred_img = pred_img.astype(np.uint8)
|
104 |
|
105 |
-
#
|
106 |
pred_img = Image.fromarray(pred_img)
|
107 |
|
108 |
return pred_img
|
109 |
|
110 |
-
#
|
111 |
iface = gr.Interface(fn=sepia, inputs="image", outputs="image")
|
112 |
|
113 |
-
#
|
114 |
-
iface.launch()
|
|
|
15 |
)
|
16 |
|
17 |
def ade_palette():
|
18 |
+
"""ADE20K ํ๋ ํธ - ๊ฐ ํด๋์ค๋ฅผ RGB ๊ฐ์ ๋งคํํฉ๋๋ค."""
|
19 |
return [
|
20 |
[204, 87, 92],
|
21 |
[112, 185, 212],
|
|
|
48 |
|
49 |
def label_to_color_image(label):
|
50 |
if label.ndim != 2:
|
51 |
+
raise ValueError("2-D ์
๋ ฅ ๋ผ๋ฒจ์ด ํ์ํฉ๋๋ค.")
|
52 |
|
53 |
if np.max(label) >= len(colormap):
|
54 |
+
raise ValueError("๋ผ๋ฒจ ๊ฐ์ด ๋๋ฌด ํฝ๋๋ค.")
|
55 |
return colormap[label]
|
56 |
|
57 |
def draw_plot(pred_img, seg):
|
|
|
76 |
return fig
|
77 |
|
78 |
def sepia(input_text):
|
79 |
+
# ์
๋ ฅ ํ
์คํธ๊ฐ ์ ํจํ ํ์ผ ๊ฒฝ๋ก์ธ์ง ํ์ธ
|
80 |
if not os.path.isfile(input_text):
|
81 |
+
return "์ ํจํ์ง ์์ ํ์ผ ๊ฒฝ๋ก์
๋๋ค. ์ ํจํ ์ด๋ฏธ์ง ํ์ผ ๊ฒฝ๋ก๋ฅผ ์
๋ ฅํด์ฃผ์ธ์."
|
82 |
|
83 |
+
# ์
๋ ฅ ํ
์คํธ๋ฅผ ์ฌ์ฉํ์ฌ ์ด๋ฏธ์ง๋ฅผ ๋ก๋ (์ด๋ฏธ์ง ํ์ผ ๊ฒฝ๋ก๋ก ๊ฐ์ )
|
84 |
input_img = Image.open(input_text)
|
85 |
|
86 |
inputs = feature_extractor(images=input_img, return_tensors="tf")
|
|
|
102 |
pred_img = np.array(input_img) * 0.5 + color_seg * 0.5
|
103 |
pred_img = pred_img.astype(np.uint8)
|
104 |
|
105 |
+
# Gradio์ ์ ํฉํ ํ์์ผ๋ก ์ด๋ฏธ์ง ๋ฐฐ์ด ๋ณํ
|
106 |
pred_img = Image.fromarray(pred_img)
|
107 |
|
108 |
return pred_img
|
109 |
|
110 |
+
# Gradio ์ธํฐํ์ด์ค ์ ์
|
111 |
iface = gr.Interface(fn=sepia, inputs="image", outputs="image")
|
112 |
|
113 |
+
# Gradio ์ฑ ์์
|
114 |
+
iface.launch()
|