Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import cv2
|
4 |
-
|
5 |
|
6 |
def inference(file, mask, model, alpha_influence, segmentation_strength):
|
7 |
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
8 |
cv2.imwrite(os.path.join("input.png"), im)
|
9 |
|
|
|
|
|
10 |
input_path = 'input.png'
|
11 |
output_path = 'output.png'
|
12 |
|
@@ -15,10 +17,10 @@ def inference(file, mask, model, alpha_influence, segmentation_strength):
|
|
15 |
input = i.read()
|
16 |
output = remove(
|
17 |
input,
|
18 |
-
session=new_session(model),
|
19 |
only_mask=(True if mask == "Mask only" else False),
|
20 |
-
|
21 |
-
|
22 |
)
|
23 |
|
24 |
o.write(output)
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import cv2
|
4 |
+
import bg # Importa el módulo "bg.py"
|
5 |
|
6 |
def inference(file, mask, model, alpha_influence, segmentation_strength):
|
7 |
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
8 |
cv2.imwrite(os.path.join("input.png"), im)
|
9 |
|
10 |
+
from rembg import new_session, remove
|
11 |
+
|
12 |
input_path = 'input.png'
|
13 |
output_path = 'output.png'
|
14 |
|
|
|
17 |
input = i.read()
|
18 |
output = remove(
|
19 |
input,
|
20 |
+
session=bg.new_session(model), # Utiliza la función de "bg.py"
|
21 |
only_mask=(True if mask == "Mask only" else False),
|
22 |
+
alpha_influence=alpha_influence, # Control de influencia del canal alfa
|
23 |
+
segmentation_strength=segmentation_strength # Control de fuerza de segmentación
|
24 |
)
|
25 |
|
26 |
o.write(output)
|