rafavidal1709 commited on
Commit
f03a97c
·
verified ·
1 Parent(s): 7447198

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ from PIL import Image
4
+
5
+ def remove_background(image):
6
+ pipe = pipeline("image-segmentation", model="briaai/RMBG-1.4", trust_remote_code=True)
7
+ pillow_mask = pipe(image, return_mask=True)
8
+ pillow_image = pipe(image)
9
+ return pillow_image
10
+
11
+ app = gr.Interface(
12
+ fn=remove_background,
13
+ inputs=gr.components.Image(type="pil"),
14
+ outputs=gr.components.Image(type="pil", format="png"), # Especificar saída como PNG
15
+ title="Remoção de Background de Imagens",
16
+ description="Envie uma imagem e veja o background sendo removido automaticamente. A imagem resultante será no formato PNG."
17
+ )
18
+
19
+ if __name__ == "__main__":
20
+ app.launch(share=True)