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_image_pil_to_tensor(image, device, size=None)
Convert an image in PIL format to a PyTorch tensor and optionally resize it.
Source code in pixano_inference/utils/media.py
convert_string_to_image(str_image)
Convert a string or path to an image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
str_image
|
str | Path
|
Image as a string or path. |
required |
Returns:
Type | Description |
---|---|
Image
|
Image. |
Source code in pixano_inference/utils/media.py
convert_string_video_to_bytes_or_path(str_video)
Convert a string to a video or video path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
str_video
|
str | Path
|
Video as a string or path. |
required |
Returns:
Type | Description |
---|---|
bytes | Path
|
The video. |
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
encode_mask_to_rle(mask)
Encode a binary mask using RLE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask
|
Tensor
|
A binary mask of shape (height, width). |
required |
Returns:
Type | Description |
---|---|
dict[str, list[int]]
|
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.