以下のコードでhdf5ファイルに保存しようとしたとき、
with h5py.File('../data/data_2.hdf5', "w") as f: group_img = f.create_group('/img') group_ann = f.create_group('/ann') for dire in tqdm.tqdm(sorted(glob.glob("../data/train_videos/*"))): data_len = len(list(glob.glob(dire + "/" + "disparity_PNG" + "/*"))) f.create_dataset( name='/img/' + dire.split("/")[-1], shape=(data_len), data=np.array(img_list[total_count:total_count+data_len]))
以下のようなエラー
ValueError: Shape tuple is incompatible with data
単純な話で、create_datasetのshapeが間違っている。これを修正すればOK。
with h5py.File('../data/data_2.hdf5', "w") as f: group_img = f.create_group('/img') group_ann = f.create_group('/ann') for dire in tqdm.tqdm(sorted(glob.glob("../data/train_videos/*"))): data_len = len(list(glob.glob(dire + "/" + "disparity_PNG" + "/*"))) f.create_dataset( name='/img/' + dire.split("/")[-1], shape=(data_len, size[0], size[1], size[2]), data=np.array(img_list[total_count:total_count+data_len]))