chansung commited on
Commit
3551e60
1 Parent(s): 68b644b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -18
app.py CHANGED
@@ -175,26 +175,12 @@ with open(r'labels.txt', 'r') as fp:
175
  for line in fp:
176
  labels_list.append(line[:-1])
177
 
178
- def label_to_color_image(label):
179
- """Adds color defined by the dataset colormap to the label.
180
-
181
- Args:
182
- label: A 2D array with integer type, storing the segmentation label.
183
-
184
- Returns:
185
- result: A 2D array with floating type. The element of the array
186
- is the color indexed by the corresponding element in the input label
187
- to the PASCAL color map.
188
 
189
- Raises:
190
- ValueError: If label is not of rank 2 or its value is larger than color
191
- map maximum entry.
192
- """
193
  if label.ndim != 2:
194
  raise ValueError("Expect 2-D input label")
195
 
196
- colormap = np.asarray(ade_palette())
197
-
198
  if np.max(label) >= len(colormap):
199
  raise ValueError("label value too large.")
200
 
@@ -238,9 +224,8 @@ def sepia(input_img):
238
  color_seg = np.zeros(
239
  (seg.shape[0], seg.shape[1], 3), dtype=np.uint8
240
  ) # height, width, 3
241
- palette = np.array(ade_palette())
242
 
243
- for label, color in enumerate(palette):
244
  color_seg[seg == label, :] = color
245
 
246
  # Convert to BGR
 
175
  for line in fp:
176
  labels_list.append(line[:-1])
177
 
178
+ colormap = np.asarray(ade_palette())
 
 
 
 
 
 
 
 
 
179
 
180
+ def label_to_color_image(label):
 
 
 
181
  if label.ndim != 2:
182
  raise ValueError("Expect 2-D input label")
183
 
 
 
184
  if np.max(label) >= len(colormap):
185
  raise ValueError("label value too large.")
186
 
 
224
  color_seg = np.zeros(
225
  (seg.shape[0], seg.shape[1], 3), dtype=np.uint8
226
  ) # height, width, 3
 
227
 
228
+ for label, color in enumerate(colormap):
229
  color_seg[seg == label, :] = color
230
 
231
  # Convert to BGR