Daankular commited on
Commit
62747da
·
1 Parent(s): efcfdf3

Fix empty_contours_guard patch: use gray_image (correct param name) not alpha

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -214,16 +214,17 @@ def load_triposg():
214
  # Patch find_bounding_box: guard against empty contours (blank alpha mask).
215
  # When RMBG produces an all-black mask, findContours returns [] and max() raises.
216
  # Fallback: return the full image bounding box so pipeline can continue.
217
- if "empty_contours_guard" not in _ip_text:
218
- _ip_text = _ip_path.read_text()
219
- _ip_text = _ip_text.replace(
 
220
  " max_contour = max(contours, key=cv2.contourArea)",
221
  " if not contours: # empty_contours_guard\n"
222
- " h, w = alpha.shape[:2]\n"
223
  " return 0, 0, w, h\n"
224
  " max_contour = max(contours, key=cv2.contourArea)",
225
  )
226
- _ip_path.write_text(_ip_text)
227
  print("[load_triposg] Patched image_process.py: empty contours guard")
228
 
229
  # Safety net: patch inference_utils.py to make diso import optional.
 
214
  # Patch find_bounding_box: guard against empty contours (blank alpha mask).
215
  # When RMBG produces an all-black mask, findContours returns [] and max() raises.
216
  # Fallback: return the full image bounding box so pipeline can continue.
217
+ # NOTE: parameter is gray_image, not alpha.
218
+ _ip_text2 = _ip_path.read_text()
219
+ if "empty_contours_guard" not in _ip_text2:
220
+ _ip_text2 = _ip_text2.replace(
221
  " max_contour = max(contours, key=cv2.contourArea)",
222
  " if not contours: # empty_contours_guard\n"
223
+ " h, w = gray_image.shape[:2]\n"
224
  " return 0, 0, w, h\n"
225
  " max_contour = max(contours, key=cv2.contourArea)",
226
  )
227
+ _ip_path.write_text(_ip_text2)
228
  print("[load_triposg] Patched image_process.py: empty contours guard")
229
 
230
  # Safety net: patch inference_utils.py to make diso import optional.