File size: 368 Bytes
19b3da3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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
|