danu9327 commited on
Commit
4905cc9
โ€ข
1 Parent(s): 2c428dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -23
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()