Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -26,7 +26,7 @@ os.system(
|
|
26 |
|
27 |
ckpt = r"models/AnimeInstanceSegmentation/rtmdetl_e60.ckpt"
|
28 |
|
29 |
-
mask_thres = 0.
|
30 |
instance_thres = 0.3
|
31 |
refine_kwargs = {
|
32 |
"refine_method": "refinenet_isnet"
|
@@ -64,8 +64,11 @@ def fn(image):
|
|
64 |
# 把mask转换为bool类型,方便后续操作
|
65 |
mask = mask.astype(np.bool_)
|
66 |
|
|
|
|
|
|
|
67 |
# 用原图中对应的区域替换白色图像中的区域,实现去除背景的效果
|
68 |
-
white[
|
69 |
|
70 |
# 给每个人物编号,然后用cv2.imwrite函数来保存图片到文件夹中
|
71 |
filename = f"person_{ii+1}.png"
|
|
|
26 |
|
27 |
ckpt = r"models/AnimeInstanceSegmentation/rtmdetl_e60.ckpt"
|
28 |
|
29 |
+
mask_thres = 0.7
|
30 |
instance_thres = 0.3
|
31 |
refine_kwargs = {
|
32 |
"refine_method": "refinenet_isnet"
|
|
|
64 |
# 把mask转换为bool类型,方便后续操作
|
65 |
mask = mask.astype(np.bool_)
|
66 |
|
67 |
+
# 对掩码进行高斯模糊,平滑边缘
|
68 |
+
mask_smoothed = cv2.GaussianBlur(mask.astype(np.float32), (3, 3), 0)
|
69 |
+
|
70 |
# 用原图中对应的区域替换白色图像中的区域,实现去除背景的效果
|
71 |
+
white[mask_smoothed > 0.5] = img2[mask_smoothed > 0.5]
|
72 |
|
73 |
# 给每个人物编号,然后用cv2.imwrite函数来保存图片到文件夹中
|
74 |
filename = f"person_{ii+1}.png"
|