diego2554 commited on
Commit
676b5d6
1 Parent(s): 3015442

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -5,7 +5,7 @@ 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):
9
  im = cv2.imread(file, cv2.IMREAD_COLOR)
10
  cv2.imwrite(os.path.join("input.png"), im)
11
 
@@ -22,6 +22,7 @@ def inference(file, mask, model, alpha_influence, segmentation_strength):
22
  alpha_matting_foreground_threshold=alpha_influence, # Control de influencia del canal alfa
23
  alpha_matting_background_threshold=1 - alpha_influence, # Control del canal alfa para el fondo
24
  alpha_matting_erode_size=int(segmentation_strength * 10), # Control de fuerza de segmentación
 
25
  session=new_session(model)
26
  )
27
 
@@ -30,7 +31,7 @@ def inference(file, mask, model, alpha_influence, segmentation_strength):
30
  return Image.open(BytesIO(output))
31
 
32
  title = "RemBG"
33
- description = "Gradio demo for RemBG. To use it, simply upload your image and adjust the alpha influence and segmentation strength."
34
  article = "<p style='text-align: center;'><a href='https://github.com/danielgatis/rembg' target='_blank'>Github Repo</a></p>"
35
 
36
  gr.Interface(
@@ -62,12 +63,14 @@ gr.Interface(
62
  ),
63
  gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.5, label="Alpha Influence"),
64
  gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.5, label="Segmentation Strength"),
 
65
  ],
66
  gr.outputs.Image(type="PIL", label="Output"),
67
  title=title,
68
  description=description,
69
  article=article,
70
- 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]],
71
  enable_queue=True
72
  ).launch()
73
 
 
 
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)
10
  cv2.imwrite(os.path.join("input.png"), im)
11
 
 
22
  alpha_matting_foreground_threshold=alpha_influence, # Control de influencia del canal alfa
23
  alpha_matting_background_threshold=1 - alpha_influence, # Control del canal alfa para el fondo
24
  alpha_matting_erode_size=int(segmentation_strength * 10), # Control de fuerza de segmentación
25
+ alpha_matting_smoothing=smoothing, # Control de suavizado de bordes de la segmentación
26
  session=new_session(model)
27
  )
28
 
 
31
  return Image.open(BytesIO(output))
32
 
33
  title = "RemBG"
34
+ description = "Gradio demo for RemBG. To use it, simply upload your image and adjust the alpha influence, segmentation strength, and smoothing."
35
  article = "<p style='text-align: center;'><a href='https://github.com/danielgatis/rembg' target='_blank'>Github Repo</a></p>"
36
 
37
  gr.Interface(
 
63
  ),
64
  gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.5, label="Alpha Influence"),
65
  gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.5, label="Segmentation Strength"),
66
+ gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.5, label="Smoothing"),
67
  ],
68
  gr.outputs.Image(type="PIL", label="Output"),
69
  title=title,
70
  description=description,
71
  article=article,
72
+ examples=[["lion.png", "Default", "u2net", 0.5, 0.5, 0.5], ["girl.jpg", "Default", "u2net", 0.5, 0.5, 0.5], ["anime-girl.jpg", "Default", "isnet-anime", 0.5, 0.5, 0.5]],
73
  enable_queue=True
74
  ).launch()
75
 
76
+