Rembg is a tool to remove images background
chore: Refactor remove function to handle unsupported input types
Daniel Gatis688b34841bd1
diff --git a/rembg/bg.py b/rembg/bg.pyindex 51f2ff9..76ebb1c 100644--- a/rembg/bg.py+++ b/rembg/bg.py@@ -241,7 +241,7 @@ def remove("""if isinstance(data, bytes) or force_return_bytes:return_type = ReturnType.BYTES- img = Image.open(io.BytesIO(data))+ img = Image.open(io.BytesIO(cast(bytes, data)))elif isinstance(data, PILImage):return_type = ReturnType.PILLOWimg = data@@ -249,7 +249,11 @@ def remove(return_type = ReturnType.NDARRAYimg = Image.fromarray(data)else:- raise ValueError("Input type {} is not supported. Try using force_return_bytes=True to force python bytes output".format(type(data)))+ raise ValueError(+ "Input type {} is not supported. Try using force_return_bytes=True to force python bytes output".format(+ type(data)+ )+ )putalpha = kwargs.pop("putalpha", False)