Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import cv2
|
|
4 |
from rembg import new_session, remove
|
5 |
from PIL import Image
|
6 |
from io import BytesIO
|
|
|
7 |
|
8 |
def inference(file, mask, model, alpha_influence, segmentation_strength, smoothing):
|
9 |
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
@@ -18,11 +19,11 @@ def inference(file, mask, model, alpha_influence, segmentation_strength, smoothi
|
|
18 |
output = remove(
|
19 |
input,
|
20 |
only_mask=(True if mask == "Mask only" else False),
|
21 |
-
alpha_matting=True,
|
22 |
-
alpha_matting_foreground_threshold=alpha_influence,
|
23 |
-
alpha_matting_background_threshold=1 - alpha_influence,
|
24 |
-
alpha_matting_erode_size=int(segmentation_strength * 10),
|
25 |
-
alpha_matting_smoothing=smoothing,
|
26 |
session=new_session(model)
|
27 |
)
|
28 |
|
@@ -69,7 +70,6 @@ gr.Interface(
|
|
69 |
],
|
70 |
[
|
71 |
gr.outputs.Image(type="PIL", label="Output"),
|
72 |
-
gr.outputs.Button(label="Download Output", type="data")
|
73 |
],
|
74 |
title=title,
|
75 |
description=description,
|
|
|
4 |
from rembg import new_session, remove
|
5 |
from PIL import Image
|
6 |
from io import BytesIO
|
7 |
+
import shutil
|
8 |
|
9 |
def inference(file, mask, model, alpha_influence, segmentation_strength, smoothing):
|
10 |
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
|
|
19 |
output = remove(
|
20 |
input,
|
21 |
only_mask=(True if mask == "Mask only" else False),
|
22 |
+
alpha_matting=True,
|
23 |
+
alpha_matting_foreground_threshold=alpha_influence,
|
24 |
+
alpha_matting_background_threshold=1 - alpha_influence,
|
25 |
+
alpha_matting_erode_size=int(segmentation_strength * 10),
|
26 |
+
alpha_matting_smoothing=smoothing,
|
27 |
session=new_session(model)
|
28 |
)
|
29 |
|
|
|
70 |
],
|
71 |
[
|
72 |
gr.outputs.Image(type="PIL", label="Output"),
|
|
|
73 |
],
|
74 |
title=title,
|
75 |
description=description,
|