EduMatthews commited on
Commit
1b962ea
·
verified ·
1 Parent(s): f14309b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
8
+ pillow_mask = pipe(image, return_mask = True)
9
+ pillow_image
10
+
11
+ return pillow_image
12
+
13
+ app = gr.Interface(
14
+ fn=remove_background,
15
+ inputs=gr.components.Image(type="pil"),
16
+ outputs=gr.components.Image(type="pil", format='png'),
17
+ title='Remoção de background de imagens',
18
+ description='Envie uma imagem e veja o background removido automaticamente. A imagem resultante será no formato PNG.'
19
+ )
20
+
21
+ if __name__ == "__main__:
22
+ app.launch(share=True)