Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,4 @@
|
|
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
|
@@ -85,27 +82,24 @@ def sepia(input_img):
|
|
85 |
logits = tf.transpose(logits, [0, 2, 3, 1])
|
86 |
logits = tf.image.resize(
|
87 |
logits, input_img.size[::-1]
|
88 |
-
)
|
89 |
seg = tf.math.argmax(logits, axis=-1)[0]
|
90 |
|
91 |
color_seg = np.zeros(
|
92 |
(seg.shape[0], seg.shape[1], 3), dtype=np.uint8
|
93 |
-
)
|
94 |
for label, color in enumerate(colormap):
|
95 |
color_seg[seg.numpy() == label, :] = color
|
96 |
|
97 |
-
#
|
98 |
-
|
99 |
-
pred_img = pred_img.astype(np.uint8)
|
100 |
-
|
101 |
-
fig = draw_plot(pred_img, seg)
|
102 |
-
return fig
|
103 |
|
|
|
104 |
demo = gr.Interface(fn=sepia,
|
105 |
inputs=gr.Image(shape=(800, 600)),
|
106 |
-
outputs=['label'],
|
107 |
examples=["cityoutdoor-1.jpg", "cityoutdoor-2.jpg", "cityoutdoor-3.jpg"],
|
108 |
allow_flagging='never')
|
109 |
|
110 |
-
|
111 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
import numpy as np
|
3 |
from PIL import Image
|
4 |
import tensorflow as tf
|
|
|
82 |
logits = tf.transpose(logits, [0, 2, 3, 1])
|
83 |
logits = tf.image.resize(
|
84 |
logits, input_img.size[::-1]
|
85 |
+
)
|
86 |
seg = tf.math.argmax(logits, axis=-1)[0]
|
87 |
|
88 |
color_seg = np.zeros(
|
89 |
(seg.shape[0], seg.shape[1], 3), dtype=np.uint8
|
90 |
+
)
|
91 |
for label, color in enumerate(colormap):
|
92 |
color_seg[seg.numpy() == label, :] = color
|
93 |
|
94 |
+
# Return segmentation label image instead of Matplotlib Figure
|
95 |
+
return color_seg
|
|
|
|
|
|
|
|
|
96 |
|
97 |
+
# Gradio Interface ์ค์
|
98 |
demo = gr.Interface(fn=sepia,
|
99 |
inputs=gr.Image(shape=(800, 600)),
|
100 |
+
outputs=['label'], # 'plot'์์ 'label'๋ก ๋ณ๊ฒฝ
|
101 |
examples=["cityoutdoor-1.jpg", "cityoutdoor-2.jpg", "cityoutdoor-3.jpg"],
|
102 |
allow_flagging='never')
|
103 |
|
104 |
+
# Gradio ์คํ
|
105 |
+
demo.launch()
|