pixano_inference.utils.media
Image utilities.
compress_rle(rle)
Compress an RLE encoded mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rle
|
dict[str, Any]
|
RLE encoded mask as a dictionary. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any | str]
|
Compressed RLE encoded mask as a string. |
Source code in pixano_inference/utils/media.py
convert_string_to_image(str_image)
Convert a string, path, or bytes reference to an image, under the media policy.
URLs are fetched with SSRF protection, timeouts, and a size cap; local paths are only
accepted when they resolve under a configured media root (see
:mod:pixano_inference.utils.media_security).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
str_image
|
str | Path | bytes
|
Image as a URL, base64 data-URI, local path, |
required |
Returns:
| Type | Description |
|---|---|
Image
|
The RGB image. |
Source code in pixano_inference/utils/media.py
convert_string_video_to_bytes_or_path(str_video)
Convert a video reference to bytes or a path, under the media policy.
URLs are fetched with SSRF protection, timeouts, and a size cap; local paths are only accepted when they resolve under a configured media root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
str_video
|
list[str | Path | bytes] | str | Path | bytes
|
Video as a URL, base64 data-URI, local path, |
required |
Returns:
| Type | Description |
|---|---|
list[bytes | Path] | bytes | Path
|
The video as bytes or a resolved |
Source code in pixano_inference/utils/media.py
decode_rle_to_mask(rle)
Decode an RLE encoded mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rle
|
dict
|
RLE encoded mask as a dictionary. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Decoded binary mask of shape (height, width). |
Source code in pixano_inference/utils/media.py
decompress_rle(rle)
Decompress a compressed RLE encoded mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rle
|
dict[str, Any]
|
Compressed RLE encoded mask as a string. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Decompressed RLE encoded mask as a dictionary. |
Source code in pixano_inference/utils/media.py
extract_media_from_base64(string)
Extract from a base64 media the actual base64 part.
Source code in pixano_inference/utils/media.py
is_base64_image(string)
Check if a string is a base64 image.
The expected format is "data:image/{image_format};base64,{base64}".
is_base64_media(string, media)
Check if a string is a base64 media.
The expected format is "data:{media}/{image_format};base64,{base64}".
is_base64_video(string)
Check if a string is a base64 video.
The expected format is "data:video/{video_format};base64,{base64}".
match_base64_media(string, media=None)
Match a base64 media.