Spaces:
Running
Running
Create app.py
Browse files
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, #função
|
13 |
+
inputs= gr.components.Image(type='pil'), #entrada (anexo do usuário)
|
14 |
+
outputs= gr.components.Image(type='pil', format='png'), #saida (download da imagem sem fundo no formato PNG)
|
15 |
+
title= 'Remoção de background de Imagens',
|
16 |
+
description= 'Envie uma imagem e veja o background removido automaticamente. A imagem resultante será no formato PNG.'
|
17 |
+
)
|
18 |
+
|
19 |
+
if __name__ == "__main__":
|
20 |
+
app.launch(share=True) #Share=True gera um link que pode ser compartilhado
|