Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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'),
|
15 |
+
title = 'Remoção de Background de Imagens',
|
16 |
+
description = 'Envie uma Imagem e veja o Backg'
|
17 |
+
)
|
18 |
+
if __name__ == "__main__":
|
19 |
+
app.launch(share=True)
|