Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does np.save() take so much space on disk

The numpy array which I am storing contains an image. The size of the image is 23.4 KB but the size of the .npy file is 4 MB

import numpy as np
from keras.preprocessing.image import load_img,img_to_array

image=load_img('image.JPEG')
array=img_to_array(image)
np.save('sample.npy',array)
like image 228
user239457 Avatar asked Dec 07 '22 15:12

user239457


1 Answers

numpy.save()

  • uncompressed binary file

if you need to compress it use

numpy.savez_compressed()

  • compressed using zipped archive
like image 83
amith murakonda Avatar answered Dec 27 '22 20:12

amith murakonda