INNER CODE UNIT · Python
save_mask
fashn-AI/fashn-vton-1.5 · scripts/debug_masks.py:64
def save_mask(mask: np.ndarray, path: str, name: str):
"""Save boolean mask as image."""
if mask.dtype == bool:
mask_img = (mask.astype(np.uint8) * 255)
else:
mask_img = mask.astype(np.uint8)
if mask_img.max() == 1:
mask_img = mask_img * 255
filepath = os.path.join(path, f"{name}.png")
cv2.imwrite(filepath, mask_img)
print(f" Saved: {filepath}")
def save_image(img: np.ndarray, path: str, name: str):
"""Save RGB image."""
filepath = os.path.join(path, f"{name}.png")
if img.shape[-1] == 3: