danu9327 commited on
Commit
1b5bd74
ยท
1 Parent(s): cc10707

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -92,6 +92,8 @@ def draw_plot(pred_img, seg):
92
  ax.tick_params(width=0.0, labelsize=25)
93
  return fig
94
 
 
 
95
  def on_mouseover(mouse_info):
96
  x, y = mouse_info["position"]
97
 
@@ -99,6 +101,7 @@ def on_mouseover(mouse_info):
99
  highlight_segmentation(x, y)
100
 
101
  def highlight_segmentation(x, y):
 
102
  # ์„ธ๊ทธ๋ฉ˜ํ…Œ์ด์…˜ ์ •๋ณด๊ฐ€ None์ด ์•„๋‹Œ ๊ฒฝ์šฐ์—๋งŒ ์ถœ๋ ฅ
103
  if seg is not None:
104
  try:
@@ -108,8 +111,9 @@ def highlight_segmentation(x, y):
108
  print(f"Invalid mouse position: ({x}, {y}), Segmentation value cannot be retrieved.")
109
  else:
110
  print("Segmentation information is not available.")
111
-
112
  def sepia(input_img):
 
113
  input_img = Image.fromarray(input_img)
114
 
115
  inputs = feature_extractor(images=input_img, return_tensors="tf")
@@ -119,8 +123,7 @@ def sepia(input_img):
119
  logits = tf.transpose(logits, [0, 2, 3, 1])
120
  logits = tf.image.resize(
121
  logits, input_img.size[::-1]
122
- ) # We reverse the shape of `image` because `image.size` returns width and height.
123
- global seg
124
  seg = tf.math.argmax(logits, axis=-1)[0]
125
 
126
  color_seg = np.zeros(
 
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
 
 
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:
 
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")
 
123
  logits = tf.transpose(logits, [0, 2, 3, 1])
124
  logits = tf.image.resize(
125
  logits, input_img.size[::-1]
126
+ ) # We reverse the shape of `image` because `image.size` returns width and height.
 
127
  seg = tf.math.argmax(logits, axis=-1)[0]
128
 
129
  color_seg = np.zeros(