Spaces:
Sleeping
Sleeping
Commit
·
3bea6ba
1
Parent(s):
a80914c
Update app.py
Browse files
app.py
CHANGED
|
@@ -82,14 +82,10 @@ def sepia(input_img):
|
|
| 82 |
logits = outputs.logits
|
| 83 |
|
| 84 |
logits = tf.transpose(logits, [0, 2, 3, 1])
|
| 85 |
-
logits = tf.image.resize(
|
| 86 |
-
logits, input_img.size[::-1]
|
| 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 |
-
)
|
| 93 |
for label, color in enumerate(colormap):
|
| 94 |
color_seg[seg.numpy() == label, :] = color
|
| 95 |
|
|
@@ -103,8 +99,8 @@ def sepia(input_img):
|
|
| 103 |
class_probabilities = {}
|
| 104 |
for label in unique_labels:
|
| 105 |
mask = (seg.numpy() == label)
|
| 106 |
-
class_name =
|
| 107 |
-
class_prob = np.mean(
|
| 108 |
class_probabilities[class_name] = class_prob
|
| 109 |
|
| 110 |
# 정확성이 가장 높은 물체 정보 얻기
|
|
@@ -115,6 +111,7 @@ def sepia(input_img):
|
|
| 115 |
print(f"Predicted class with highest probability: {max_prob_class}, Probability: {max_prob_value:.4f}")
|
| 116 |
return fig, f"Predicted class with highest probability: {max_prob_class}, Probability: {max_prob_value:.4f}"
|
| 117 |
|
|
|
|
| 118 |
demo = gr.Interface(fn=sepia,
|
| 119 |
inputs=gr.Image(shape=(400, 600)),
|
| 120 |
outputs=['plot', 'text'],
|
|
|
|
| 82 |
logits = outputs.logits
|
| 83 |
|
| 84 |
logits = tf.transpose(logits, [0, 2, 3, 1])
|
| 85 |
+
logits = tf.image.resize(logits, input_img.size[::-1])
|
|
|
|
|
|
|
| 86 |
seg = tf.math.argmax(logits, axis=-1)[0]
|
| 87 |
|
| 88 |
+
color_seg = np.zeros((seg.shape[0], seg.shape[1], 3), dtype=np.uint8)
|
|
|
|
|
|
|
| 89 |
for label, color in enumerate(colormap):
|
| 90 |
color_seg[seg.numpy() == label, :] = color
|
| 91 |
|
|
|
|
| 99 |
class_probabilities = {}
|
| 100 |
for label in unique_labels:
|
| 101 |
mask = (seg.numpy() == label)
|
| 102 |
+
class_name = labels_list[label]
|
| 103 |
+
class_prob = np.mean(logits.numpy()[0][mask])
|
| 104 |
class_probabilities[class_name] = class_prob
|
| 105 |
|
| 106 |
# 정확성이 가장 높은 물체 정보 얻기
|
|
|
|
| 111 |
print(f"Predicted class with highest probability: {max_prob_class}, Probability: {max_prob_value:.4f}")
|
| 112 |
return fig, f"Predicted class with highest probability: {max_prob_class}, Probability: {max_prob_value:.4f}"
|
| 113 |
|
| 114 |
+
|
| 115 |
demo = gr.Interface(fn=sepia,
|
| 116 |
inputs=gr.Image(shape=(400, 600)),
|
| 117 |
outputs=['plot', 'text'],
|