huzey commited on
Commit
51d0dee
1 Parent(s): 62031d2
Files changed (1) hide show
  1. app.py +3 -13
app.py CHANGED
@@ -119,10 +119,9 @@ def dont_use_too_much_green(image_rgb):
119
  return image_rgb
120
 
121
 
122
- def to_pil_images(images):
123
  size = images[0].shape[1]
124
- target = 256
125
- multiplier = target // size
126
  res = int(size * multiplier)
127
  return [
128
  Image.fromarray((image * 255).cpu().numpy().astype(np.uint8)).resize((res, res), Image.Resampling.NEAREST)
@@ -337,20 +336,11 @@ def ncut_run(
337
  galleries = []
338
  for i_node in range(rgb.shape[1]):
339
  _rgb = rgb[:, i_node]
340
- galleries.append(to_pil_images(_rgb))
341
  return *galleries, logging_str
342
 
343
  rgb = dont_use_too_much_green(rgb)
344
 
345
- if "AlignedThreeModelAttnNodes" == model_name:
346
- # dirty patch for the alignedcut paper
347
- print("AlignedThreeModelAttnNodes")
348
- galleries = []
349
- for i_node in range(rgb.shape[1]):
350
- _rgb = rgb[:, i_node]
351
- print(_rgb.shape)
352
- galleries.append(to_pil_images(_rgb))
353
- return *galleries, logging_str
354
 
355
  if video_output:
356
  video_path = get_random_path()
 
119
  return image_rgb
120
 
121
 
122
+ def to_pil_images(images, target_size=256):
123
  size = images[0].shape[1]
124
+ multiplier = target_size // size
 
125
  res = int(size * multiplier)
126
  return [
127
  Image.fromarray((image * 255).cpu().numpy().astype(np.uint8)).resize((res, res), Image.Resampling.NEAREST)
 
336
  galleries = []
337
  for i_node in range(rgb.shape[1]):
338
  _rgb = rgb[:, i_node]
339
+ galleries.append(to_pil_images(_rgb, target_size=56))
340
  return *galleries, logging_str
341
 
342
  rgb = dont_use_too_much_green(rgb)
343
 
 
 
 
 
 
 
 
 
 
344
 
345
  if video_output:
346
  video_path = get_random_path()