I am looking for the best way to send large Numpy arrays (composed mainly of images) via Flask.
For now, I am now doing something like this:
Server side:
np.save(matrix_path, my_array)
return send_file(matrix_path+'.npy')
Client side:
with open('test_temp', 'wb') as f:
f.write(r.content)
my_array = np.load('test_temp')
But the .npy file is very large so it takes too long.
I thought about using h5py but as the images have different size (array.shape = (200,)
), I cannot use h5py (create a dataset for each image would be too long).
Does anyone get an idea of how to optimize this?