mistral_common.multimodal
download_image(url)
Download an image from a URL and return it as a PIL Image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL of the image to download. |
required |
Returns:
Type | Description |
---|---|
Image
|
The downloaded image as a PIL Image object. |
Source code in src/mistral_common/multimodal.py
maybe_load_image_from_str_or_bytes(x)
Load an image from a string or bytes.
If the input is already a PIL Image, return it as is.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
Union[Image, str, bytes]
|
The input to load the image from. Can be a PIL Image, a string, or bytes. If it's a string, it's assumed to be a base64 encoded string of bytes. |
required |
Returns:
Type | Description |
---|---|
Image
|
The loaded image as a PIL Image object. |
Source code in src/mistral_common/multimodal.py
serialize_image_to_byte_str(im, info)
Serialize an image to a base64 encoded string of bytes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
im
|
Image
|
The image to serialize. |
required |
info
|
SerializationInfo
|
The serialization info. |
required |
Returns:
Type | Description |
---|---|
str
|
The serialized image as a base64 encoded string of bytes. |