diego2554 commited on
Commit
782da61
1 Parent(s): df195bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  import os
3
  import cv2
4
 
5
- def inference(file, mask, model):
6
  im = cv2.imread(file, cv2.IMREAD_COLOR)
7
  cv2.imwrite(os.path.join("input.png"), im)
8
 
@@ -16,20 +16,18 @@ def inference(file, mask, model):
16
  input = i.read()
17
  output = remove(
18
  input,
19
- session = new_session(model),
20
- only_mask = (True if mask == "Mask only" else False)
21
- )
22
-
23
-
24
-
25
  o.write(output)
26
  return os.path.join("output.png")
27
-
28
  title = "RemBG"
29
- description = "Gradio demo for RemBG. To use it, simply upload your image and wait. Read more at the link below."
30
  article = "<p style='text-align: center;'><a href='https://github.com/danielgatis/rembg' target='_blank'>Github Repo</a></p>"
31
 
32
-
33
  gr.Interface(
34
  inference,
35
  [
@@ -52,16 +50,18 @@ gr.Interface(
52
  "isnet-general-use",
53
  "isnet-anime",
54
  "sam",
55
- ],
56
- type="value",
57
- default="isnet-general-use",
58
- label="Models"
59
  ),
 
 
60
  ],
61
  gr.outputs.Image(type="filepath", label="Output"),
62
  title=title,
63
  description=description,
64
  article=article,
65
- examples=[["lion.png", "Default", "u2net"], ["girl.jpg", "Default", "u2net"], ["anime-girl.jpg", "Default", "isnet-anime"]],
66
  enable_queue=True
67
- ).launch()
 
2
  import os
3
  import cv2
4
 
5
+ def inference(file, mask, model, alpha_influence, segmentation_strength):
6
  im = cv2.imread(file, cv2.IMREAD_COLOR)
7
  cv2.imwrite(os.path.join("input.png"), im)
8
 
 
16
  input = i.read()
17
  output = remove(
18
  input,
19
+ session=new_session(model),
20
+ alpha_influence=alpha_influence, # Control de influencia del canal alfa
21
+ segmentation_strength=segmentation_strength # Control de fuerza de segmentación
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(
32
  inference,
33
  [
 
50
  "isnet-general-use",
51
  "isnet-anime",
52
  "sam",
53
+ ],
54
+ type="value",
55
+ default="isnet-general-use",
56
+ label="Models"
57
  ),
58
+ gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.5, label="Alpha Influence"),
59
+ gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.5, label="Segmentation Strength"),
60
  ],
61
  gr.outputs.Image(type="filepath", label="Output"),
62
  title=title,
63
  description=description,
64
  article=article,
65
+ examples=[["lion.png", "Default", "u2net", 0.5, 0.5], ["girl.jpg", "Default", "u2net", 0.5, 0.5], ["anime-girl.jpg", "Default", "isnet-anime", 0.5, 0.5]],
66
  enable_queue=True
67
+ ).launch()