CM2000112 / internals /pipelines /remove_background.py
jayparmr's picture
Upload 118 files
19b3da3
raw
history blame
368 Bytes
import io
from typing import Union
from PIL import Image
from rembg import remove
from internals.util.commons import read_url
class RemoveBackground:
def remove(self, image: Union[str, Image.Image]) -> Image.Image:
if type(image) is str:
image = Image.open(io.BytesIO(read_url(image)))
output = remove(image)
return output