opsiclear-admin commited on
Commit
abc74df
·
verified ·
1 Parent(s): 086253d

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -398,6 +398,7 @@ def prepare_multi_example() -> List[Image.Image]:
398
  """
399
  Prepare multi-image examples for the gallery.
400
  Adds transparent gaps between images for split_image to detect boundaries.
 
401
  """
402
  multi_case = list(set([i.split('_')[0] for i in os.listdir("assets/example_multi_image")]))
403
  images = []
@@ -406,15 +407,20 @@ def prepare_multi_example() -> List[Image.Image]:
406
  _images = []
407
  # Add leading gap for boundary detection
408
  _images.append(np.zeros((512, gap_width, 4), dtype=np.uint8))
409
- for i in range(1, 4):
410
- img = Image.open(f'assets/example_multi_image/{case}_{i}.png')
 
 
 
 
411
  W, H = img.size
412
  img = img.resize((int(W / H * 512), 512))
413
  img_array = np.array(img.convert('RGBA'))
414
  _images.append(img_array)
415
  # Add transparent gap after each image
416
  _images.append(np.zeros((512, gap_width, 4), dtype=np.uint8))
417
- images.append(Image.fromarray(np.concatenate(_images, axis=1)))
 
418
  return images
419
 
420
 
 
398
  """
399
  Prepare multi-image examples for the gallery.
400
  Adds transparent gaps between images for split_image to detect boundaries.
401
+ Supports variable number of views per case (up to 6).
402
  """
403
  multi_case = list(set([i.split('_')[0] for i in os.listdir("assets/example_multi_image")]))
404
  images = []
 
407
  _images = []
408
  # Add leading gap for boundary detection
409
  _images.append(np.zeros((512, gap_width, 4), dtype=np.uint8))
410
+ # Load all available views (1-6)
411
+ for i in range(1, 7):
412
+ img_path = f'assets/example_multi_image/{case}_{i}.png'
413
+ if not os.path.exists(img_path):
414
+ continue
415
+ img = Image.open(img_path)
416
  W, H = img.size
417
  img = img.resize((int(W / H * 512), 512))
418
  img_array = np.array(img.convert('RGBA'))
419
  _images.append(img_array)
420
  # Add transparent gap after each image
421
  _images.append(np.zeros((512, gap_width, 4), dtype=np.uint8))
422
+ if len(_images) > 1: # Has at least one image
423
+ images.append(Image.fromarray(np.concatenate(_images, axis=1)))
424
  return images
425
 
426