diego2554 commited on
Commit
5df93e6
1 Parent(s): a814d9e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
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)
@@ -20,15 +21,15 @@ def inference(file, mask, model, alpha_influence, segmentation_strength):
20
  input,
21
  session=new_session(model),
22
  only_mask=(True if mask == "Mask only" else False),
23
- alpha=alpha_influence,
24
- bg_color=(0, 0, 0, segmentation_strength)
25
  )
26
  o.write(output)
27
  m.write(output)
28
 
29
  return os.path.join("output.png"), os.path.join("mask.png")
30
 
31
- title = "RemBG_Super"
32
  description = "Gradio demo for RemBG. To use it, simply upload your image and adjust the alpha influence and segmentation strength."
33
  article = "<p style='text-align: center;'><a href='https://github.com/danielgatis/rembg' target='_blank'>Github Repo</a></p>"
34
 
@@ -71,8 +72,8 @@ iface = gr.Interface(
71
  gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.5, label="Segmentation Strength"),
72
  ],
73
  [
74
- gr.outputs.Image(type="plot", label="Processed Image"),
75
- gr.outputs.Image(type="plot", label="Processed Mask"),
76
  ],
77
  title=title,
78
  description=description,
 
1
  import gradio as gr
2
  import os
3
  import cv2
4
+ import numpy as np
5
 
6
  def inference(file, mask, model, alpha_influence, segmentation_strength):
7
  im = cv2.imread(file, cv2.IMREAD_COLOR)
 
21
  input,
22
  session=new_session(model),
23
  only_mask=(True if mask == "Mask only" else False),
24
+ alpha=alpha_influence, # Control de influencia del canal alfa
25
+ bg_color=(0, 0, 0, segmentation_strength) # Control de fuerza de segmentación
26
  )
27
  o.write(output)
28
  m.write(output)
29
 
30
  return os.path.join("output.png"), os.path.join("mask.png")
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
 
 
72
  gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.5, label="Segmentation Strength"),
73
  ],
74
  [
75
+ gr.outputs.Image(type="plot", label="Processed Image", output=show_processed_image),
76
+ gr.outputs.Image(type="plot", label="Processed Mask", output=show_processed_mask),
77
  ],
78
  title=title,
79
  description=description,