MCPcopy Create free account
hub / github.com/modelscope/modelscope / encode_array_to_img_base64

Function encode_array_to_img_base64

modelscope/utils/service_utils.py:97–104  ·  view source on GitHub ↗
(image_array)

Source from the content-addressed store, hash-verified

95
96
97def encode_array_to_img_base64(image_array):
98 from PIL import Image
99 with BytesIO() as output_bytes:
100 pil_image = Image.fromarray(image_array.astype(np.uint8))
101 pil_image.save(output_bytes, 'PNG')
102 bytes_data = output_bytes.getvalue()
103 base64_str = str(base64.b64encode(bytes_data), 'utf-8')
104 return 'data:image/png;base64,' + base64_str
105
106
107def encode_pcm_to_base64(bytes_data):

Callers 2

ExampleEncoderFunction · 0.85
service_data_encoderFunction · 0.85

Calls 1

saveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…