Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import cv2
|
4 |
-
from
|
5 |
-
from RemBG_super/rembg/bg import remove as bg_remove # Importa la función 'remove' desde bg.py
|
6 |
|
7 |
def inference(file, mask, model, alpha_influence, segmentation_strength):
|
8 |
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
@@ -14,22 +13,19 @@ def inference(file, mask, model, alpha_influence, segmentation_strength):
|
|
14 |
with open(input_path, 'rb') as i:
|
15 |
with open(output_path, 'wb') as o:
|
16 |
input = i.read()
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
alpha_influence=alpha_influence,
|
25 |
-
bg_color=(0, 0, 0, segmentation_strength)
|
26 |
-
)
|
27 |
|
28 |
o.write(output)
|
29 |
return os.path.join("output.png")
|
30 |
|
31 |
-
title = "RemBG
|
32 |
-
description = "Gradio demo for RemBG
|
33 |
article = "<p style='text-align: center;'><a href='https://github.com/danielgatis/rembg' target='_blank'>Github Repo</a></p>"
|
34 |
|
35 |
gr.Interface(
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import cv2
|
4 |
+
from bg import remove
|
|
|
5 |
|
6 |
def inference(file, mask, model, alpha_influence, segmentation_strength):
|
7 |
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
|
|
13 |
with open(input_path, 'rb') as i:
|
14 |
with open(output_path, 'wb') as o:
|
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 |
+
alpha=alpha_influence,
|
21 |
+
bg_color=(0, 0, 0, segmentation_strength)
|
22 |
+
)
|
|
|
|
|
|
|
23 |
|
24 |
o.write(output)
|
25 |
return os.path.join("output.png")
|
26 |
|
27 |
+
title = "RemBG"
|
28 |
+
description = "Gradio demo for RemBG. To use it, simply upload your image and adjust the alpha influence and segmentation strength."
|
29 |
article = "<p style='text-align: center;'><a href='https://github.com/danielgatis/rembg' target='_blank'>Github Repo</a></p>"
|
30 |
|
31 |
gr.Interface(
|