Encoding
bytes_to_opencv_image(payload, array_type=np.uint8)
¶
Decode a bytes object to an OpenCV image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
payload
|
bytes
|
The bytes object to decode. |
required |
array_type
|
number
|
The type of the array. |
uint8
|
Returns:
Type | Description |
---|---|
ndarray
|
The OpenCV image. |
Source code in inference_sdk/http/utils/encoding.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
bytes_to_pillow_image(payload)
¶
Decode a bytes object to a PIL image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
payload
|
bytes
|
The bytes object to decode. |
required |
Returns:
Type | Description |
---|---|
Image
|
The PIL image. |
Source code in inference_sdk/http/utils/encoding.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
encode_base_64(payload)
¶
Encode a bytes object to a base64 string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
payload
|
bytes
|
The bytes object to encode. |
required |
Returns:
Type | Description |
---|---|
str
|
The base64 string. |
Source code in inference_sdk/http/utils/encoding.py
42 43 44 45 46 47 48 49 50 51 |
|
numpy_array_to_base64_jpeg(image)
¶
Encode a numpy array to a base64 JPEG string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
ndarray
|
The numpy array to encode. |
required |
Returns:
Type | Description |
---|---|
Union[str]
|
The base64 JPEG string. |
Source code in inference_sdk/http/utils/encoding.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
pillow_image_to_base64_jpeg(image)
¶
Encode a PIL image to a base64 JPEG string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
Image
|
The PIL image to encode. |
required |
Returns:
Type | Description |
---|---|
str
|
The base64 JPEG string. |
Source code in inference_sdk/http/utils/encoding.py
28 29 30 31 32 33 34 35 36 37 38 39 |
|