Spaces:
Build error
Build error
| import gradio as gr | |
| from transformers import pipeline | |
| from PIL import Image | |
| #função para a remoção do backgroud | |
| def remove_background(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) # applies mask on input and returns a pillow image | |
| return pillow_image | |
| #gerando a aplicação gradio | |
| app = gr.Interface( | |
| fn=remove_background, | |
| inputs=gr.components.Image(type = 'pil'), | |
| outputs=gr.components.Image(type = 'pil', format = 'png'), | |
| title = 'Remoção de Background', | |
| description = 'Envie uma imagem que você queira remover o background' | |
| ) | |
| if __name__ == '__main__': | |
| app.launch(share=True) | |