testtest123 commited on
Commit
856084d
·
1 Parent(s): cdc3c72

Fix mask array type for C++ backend

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -427,16 +427,16 @@ def gradio_estimate(
427
  editor_mask = np.array(editor_mask)
428
  if editor_mask.ndim == 3 and editor_mask.shape[2] >= 4:
429
  alpha = editor_mask[:, :, 3]
430
- mask = (alpha > 0).astype(np.uint8) * 255
431
  elif editor_mask.ndim == 3:
432
  gray = cv2.cvtColor(editor_mask, cv2.COLOR_RGB2GRAY)
433
- mask = (gray > 0).astype(np.uint8) * 255
434
  elif editor_mask.ndim == 2:
435
- mask = (editor_mask > 0).astype(np.uint8) * 255
436
  else:
437
  return "Error: Unsupported editor mask format", query_image, None
438
 
439
- debug_mask = mask
440
 
441
  # Estimate pose
442
  result = pose_estimator.estimate_pose(
 
427
  editor_mask = np.array(editor_mask)
428
  if editor_mask.ndim == 3 and editor_mask.shape[2] >= 4:
429
  alpha = editor_mask[:, :, 3]
430
+ mask = (alpha > 0).astype(bool)
431
  elif editor_mask.ndim == 3:
432
  gray = cv2.cvtColor(editor_mask, cv2.COLOR_RGB2GRAY)
433
+ mask = (gray > 0).astype(bool)
434
  elif editor_mask.ndim == 2:
435
+ mask = (editor_mask > 0).astype(bool)
436
  else:
437
  return "Error: Unsupported editor mask format", query_image, None
438
 
439
+ debug_mask = (mask.astype(np.uint8) * 255)
440
 
441
  # Estimate pose
442
  result = pose_estimator.estimate_pose(