DDingcheol commited on
Commit
ac55567
ยท
1 Parent(s): f6cf171

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -87,6 +87,8 @@ def sepia(input_img):
87
  )
88
  seg = tf.math.argmax(logits, axis=-1)[0]
89
 
 
 
90
  color_seg = np.zeros(
91
  (seg.shape[0], seg.shape[1], 3), dtype=np.uint8
92
  )
@@ -97,14 +99,19 @@ def sepia(input_img):
97
  pred_img = pred_img.astype(np.uint8)
98
 
99
  fig = draw_plot(pred_img, seg)
100
-
 
 
 
 
 
 
101
  return fig
102
 
103
  demo = gr.Interface(fn=sepia,
104
  inputs=gr.Image(shape=(400, 600)),
105
- outputs=['plot'],
106
  examples=["citiscapes-1.jpeg", "citiscapes-2.jpeg"],
107
  allow_flagging='never')
108
 
109
-
110
  demo.launch()
 
87
  )
88
  seg = tf.math.argmax(logits, axis=-1)[0]
89
 
90
+ probabilities = tf.nn.softmax(logits, axis=-1)[0] # ํ™•๋ฅ ๊ฐ’ ์ถ”์ถœ
91
+
92
  color_seg = np.zeros(
93
  (seg.shape[0], seg.shape[1], 3), dtype=np.uint8
94
  )
 
99
  pred_img = pred_img.astype(np.uint8)
100
 
101
  fig = draw_plot(pred_img, seg)
102
+
103
+ # ๊ฐ ํด๋ž˜์Šค์˜ ํ™•๋ฅ ์„ ์ถœ๋ ฅ
104
+ class_probabilities = {
105
+ labels_list[i]: probabilities[:, :, i].numpy() for i in range(len(labels_list))
106
+ }
107
+ print(class_probabilities)
108
+
109
  return fig
110
 
111
  demo = gr.Interface(fn=sepia,
112
  inputs=gr.Image(shape=(400, 600)),
113
+ outputs=["plot", "text"],
114
  examples=["citiscapes-1.jpeg", "citiscapes-2.jpeg"],
115
  allow_flagging='never')
116
 
 
117
  demo.launch()