jeroavf commited on
Commit
0c2356c
·
verified ·
1 Parent(s): 0ea6e37

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """InterfaceRemoveBackground.ipynb
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1c2CqhHMVR1qncca5n-8l9MrF4SGk3cKa
8
+ """
9
+
10
+ #!pip install gradio
11
+
12
+ import gradio as gr
13
+ from transformers import pipeline
14
+ from PIL import Image
15
+
16
+ def remove_background(image):
17
+ pipe = pipeline("image-segmentation",model="briaai/RMBG-1.4",trust_remote_code=True)
18
+ pillow_mask = pipe(image,return_mask=True )
19
+ pillow_image = pipe(image)
20
+ return pillow_image
21
+
22
+ app = gr.Interface(
23
+ fn=remove_background,
24
+ inputs=gr.components.Image(type="pil"),
25
+ outputs=gr.components.Image(type="pil",format="png"),
26
+ title="Remoção de Background de Imagens",
27
+ description="Envie uma imagem e veja o background sendo removido automaticamente. A imagem resultante será no formato PNG."
28
+
29
+ )
30
+
31
+ if __name__ == "__main__":
32
+ app.launch(share=True)
33
+