MCPcopy
hub / github.com/landing-ai/vision-agent / numpy_to_bytes

Function numpy_to_bytes

vision_agent/utils/image_utils.py:122–128  ·  view source on GitHub ↗
(image: np.ndarray)

Source from the content-addressed store, hash-verified

120
121
122def numpy_to_bytes(image: np.ndarray) -> bytes:
123 pil_image = Image.fromarray(image).convert("RGB")
124 image_buffer = io.BytesIO()
125 pil_image.save(image_buffer, format="PNG")
126 buffer_bytes = image_buffer.getvalue()
127 image_buffer.close()
128 return buffer_bytes
129
130
131def get_image_size(data: Union[str, Path, np.ndarray, ImageType]) -> Tuple[int, ...]:

Callers 15

instance_segmentationFunction · 0.90
ocrFunction · 0.90
depth_estimationFunction · 0.90
_sam2Function · 0.90
_owlv2_object_detectionFunction · 0.90
custom_object_detectionFunction · 0.90
_glee_object_detectionFunction · 0.90

Calls 2

saveMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected