Update app.py
Browse files
app.py
CHANGED
@@ -92,28 +92,7 @@ def draw_plot(pred_img, seg):
|
|
92 |
ax.tick_params(width=0.0, labelsize=25)
|
93 |
return fig
|
94 |
|
95 |
-
seg = None
|
96 |
-
|
97 |
-
def on_mouseover(mouse_info):
|
98 |
-
x, y = mouse_info["position"]
|
99 |
-
|
100 |
-
# ์ฌ์ฉ์ ์ ์ ํจ์๋ฅผ ํธ์ถํ์ฌ ํน์ ์์ญ์ ๊ฐ์กฐ
|
101 |
-
highlight_segmentation(x, y)
|
102 |
-
|
103 |
-
def highlight_segmentation(x, y):
|
104 |
-
global seg # ์ ์ญ ๋ณ์๋ก ์ ์ธํ์ฌ ๋ง์ฐ์ค ์ด๋ฒคํธ์์ ์ฌ์ฉํ ์ ์๋๋ก ํจ
|
105 |
-
# ์ธ๊ทธ๋ฉํ
์ด์
์ ๋ณด๊ฐ None์ด ์๋ ๊ฒฝ์ฐ์๋ง ์ถ๋ ฅ
|
106 |
-
if seg is not None:
|
107 |
-
try:
|
108 |
-
seg_value = seg.numpy()[y, x]
|
109 |
-
print(f"Mouse over position: ({x}, {y}), Segmentation value: {seg_value}")
|
110 |
-
except (AttributeError, IndexError):
|
111 |
-
print(f"Invalid mouse position: ({x}, {y}), Segmentation value cannot be retrieved.")
|
112 |
-
else:
|
113 |
-
print("Segmentation information is not available.")
|
114 |
-
|
115 |
def sepia(input_img):
|
116 |
-
global seg
|
117 |
input_img = Image.fromarray(input_img)
|
118 |
|
119 |
inputs = feature_extractor(images=input_img, return_tensors="tf")
|
@@ -145,7 +124,6 @@ demo = gr.Interface(fn=sepia,
|
|
145 |
title="Gradio ๊ธฐ๋ฐ์ Hugging Face ์์ ๋ถํ ๋ชจ๋ธ ๋ฐ๋ชจ ๊ตฌํ ๊ณผ์ 3",
|
146 |
description="์ฐจ๋, ์ธ๋, ์์ ๊ฑฐ๋๋ก ๋ฑ์ ์ฌ์ง๋ง ๋ฃ์ด์ฃผ์ธ์",
|
147 |
examples=["example1.jpg", "example2.jpg", "example3.jpeg", "example4.jpg"],
|
148 |
-
allow_flagging='never'
|
149 |
-
events=[gr.Mouse(on_mouseover)])
|
150 |
|
151 |
demo.launch()
|
|
|
92 |
ax.tick_params(width=0.0, labelsize=25)
|
93 |
return fig
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
def sepia(input_img):
|
|
|
96 |
input_img = Image.fromarray(input_img)
|
97 |
|
98 |
inputs = feature_extractor(images=input_img, return_tensors="tf")
|
|
|
124 |
title="Gradio ๊ธฐ๋ฐ์ Hugging Face ์์ ๋ถํ ๋ชจ๋ธ ๋ฐ๋ชจ ๊ตฌํ ๊ณผ์ 3",
|
125 |
description="์ฐจ๋, ์ธ๋, ์์ ๊ฑฐ๋๋ก ๋ฑ์ ์ฌ์ง๋ง ๋ฃ์ด์ฃผ์ธ์",
|
126 |
examples=["example1.jpg", "example2.jpg", "example3.jpeg", "example4.jpg"],
|
127 |
+
allow_flagging='never')
|
|
|
128 |
|
129 |
demo.launch()
|