Spaces:
Build error
Build error
File size: 1,053 Bytes
e151d05 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import gradio as gr
from rembg import remove
from PIL import Image
import io
def remove_background(input_image):
# Преобразуем изображение в байты
img_byte_arr = io.BytesIO()
input_image.save(img_byte_arr, format='PNG')
img_byte_arr = img_byte_arr.getvalue()
# Удаляем фон с помощью модели RemBgV0
output_image = remove(img_byte_arr)
# Преобразуем результат обратно в изображение
output_image = Image.open(io.BytesIO(output_image))
return output_image
# Создаем Gradio интерфейс
iface = gr.Interface(
fn=remove_background,
inputs=gr.Image(type="pil", label="Входное изображение"),
outputs=gr.Image(type="pil", label="Изображение без фона"),
title="Удаление фона с помощью RemBgV0",
description="Загрузите изображение, чтобы удалить фон."
)
# Запускаем интерфейс
iface.launch() |