add image input type

Former-commit-id: ffa39ba3db0dbfd375cdf20b9f3cbecd359be1a1
This commit is contained in:
hiyouga 2024-11-04 08:27:20 +00:00
parent 2360d63ebc
commit 1598e5d355

View File

@ -30,7 +30,7 @@ if TYPE_CHECKING:
path: Optional[str]
bytes: Optional[bytes]
ImageInput = Union[str, EncodedImage, ImageObject]
ImageInput = Union[str, bytes, EncodedImage, ImageObject]
VideoInput = str
@ -104,6 +104,8 @@ class BasePlugin:
for image in images:
if isinstance(image, str):
image = Image.open(image)
elif isinstance(image, bytes):
image = Image.open(BytesIO(image))
elif isinstance(image, dict):
if image["bytes"] is not None:
image = Image.open(BytesIO(image["bytes"]))