LogicGoInfotechSpaces commited on
Commit
d7d0150
·
1 Parent(s): 515adea

Ensure mask matches resized image size

Browse files
Files changed (1) hide show
  1. src/core.py +4 -7
src/core.py CHANGED
@@ -508,13 +508,10 @@ def process_inpaint(image, mask, invert_mask=True):
508
  mask = 255 - mask # invert: white becomes black, black becomes white
509
  print(f"Applied invert_mask=False: inverted RGB mask (now black=remove)")
510
 
511
- # Resize mask to match image dimensions
512
- if size_limit < max_dimension:
513
- mask = resize_max_size(mask, size_limit=size_limit, interpolation=cv2.INTER_NEAREST)
514
- else:
515
- # Ensure mask matches image dimensions
516
- if mask.shape[:2] != image_resized.shape[:2]:
517
- mask = cv2.resize(mask, (image_resized.shape[1], image_resized.shape[0]), interpolation=cv2.INTER_NEAREST)
518
 
519
  # Debug: log final mask statistics
520
  mask_nonzero = int((mask > 128).sum())
 
508
  mask = 255 - mask # invert: white becomes black, black becomes white
509
  print(f"Applied invert_mask=False: inverted RGB mask (now black=remove)")
510
 
511
+ # Resize mask to match image dimensions (always force exact match)
512
+ target_h, target_w = image_resized.shape[:2]
513
+ if mask.shape[:2] != (target_h, target_w):
514
+ mask = cv2.resize(mask, (target_w, target_h), interpolation=cv2.INTER_NEAREST)
 
 
 
515
 
516
  # Debug: log final mask statistics
517
  mask_nonzero = int((mask > 128).sum())