mirror of
https://git.mirrors.martin98.com/https://github.com/danielgatis/rembg
synced 2025-08-19 21:59:08 +08:00
chore: Refactor remove function to handle unsupported input types
This commit is contained in:
parent
90536b6858
commit
688b34841b
@ -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.PILLOW
|
||||
img = data
|
||||
@ -249,7 +249,11 @@ def remove(
|
||||
return_type = ReturnType.NDARRAY
|
||||
img = 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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user