尝试将50000((32、32、3)个图片文件)附加到h5py文件中
但问题是内存。
我尝试追加一张图片,然后再次阅读并再次追加
但是,内存不会减少
写入h5py文件后,有什么方法可以刷新内存? (使用pycharm)
with h5py.File(self.datapath, 'a') as hf:
i = hf['saliencys'].shape[0] + 1
#print('i value->', i)
if i==idx:
#print('i->',i , 'and ', idx )
#idx = hf['saliencys'].shape[0]
sal_maps_b,outputcam_b,heat_map_b, probs_b, preds_b = self.generate_image(img, idx)
sal_maps_b = np.transpose(sal_maps_b, axes=(3,0, 1, 2))
if i%500==0:
print('appending....original saliency shape->{} {}/50000%'.format(hf["saliencys"].shape,i ))
dset = hf['saliencys']
dset.resize((i + 1,) + img_size)
dset[i] = [sal_maps_b]