Spaces:
Build error

segmenta_image / app.py
srTeco's picture
Create app.py
206cb2f verified
Raw History Blame Contribute Delete
666 Bytes
import gradio as gd
from transformers import pipeline
from PIL import Image
def remove_bg(image):
pipe = pipeline(
"image-segmentation", model="briaai/RMBG-1.4", trust_remote_code=True
)
pillow_mask = pipe(image, return_mask=True) # outputs a pillow mask
pillow_image = pipe(image)
return pillow_image
# remove_bg("image\IMG_0637.jpg")
app = gd.Interface(
title="REMOVE BACKGROUND IMAGE",
description="Faça upload da imagem para remover o bg",
fn=remove_bg,
inputs=gd.components.Image(type="pil"),
outputs=gd.components.Image(type="pil", format="png"),
)
if __name__ == "__main__":
app.launch(share=True)