IOPaint/iopaint/tests/test_adjust_mask.py

16 lines
599 B
Python
Raw Normal View History

2024-01-05 07:57:30 +01:00
import cv2
2024-01-05 08:19:23 +01:00
from iopaint.helper import adjust_mask
from iopaint.tests.utils import current_dir, save_dir
2024-01-05 07:57:30 +01:00
mask_p = current_dir / "overture-creations-5sI6fQgYIuo_mask.png"
def test_adjust_mask():
mask = cv2.imread(str(mask_p), cv2.IMREAD_GRAYSCALE)
res_mask = adjust_mask(mask, 0, "expand")
cv2.imwrite(str(save_dir / "adjust_mask_original.png"), res_mask)
res_mask = adjust_mask(mask, 40, "expand")
cv2.imwrite(str(save_dir / "adjust_mask_expand.png"), res_mask)
res_mask = adjust_mask(mask, 20, "shrink")
cv2.imwrite(str(save_dir / "adjust_mask_shrink.png"), res_mask)