picture of all the plant dataset h5 files in one directory
I have multiple .h5 files with plant datasets trained from a Siamese model. i m trying to combine all into one h5 file for evaluation. i can correctly evaluate each h5 file individually for the most part. but after view this link Combining hdf5 files and evaluating the combined h5 file i was hit with an error. any ideas on what might work combining the h5 files one on with out affecting the "shape"?
import h5py
import glob
with h5py.File('table_merge.h5',mode='w') as h5fw:
row1 = 0
for h5name in glob.glob('*.h5'):
h5fr = h5py.File(h5name,'r')
dset1 = list(h5fr.keys())[0]
arr_data = h5fr[dset1][:]
dslen = arr_data.shape[0]
cols = arr_data.shape[1]
if row1 == 0:
h5fw.create_dataset('alldata', dtype="f", shape=(dslen,cols), maxshape=(None, cols) )
if row1+dslen <= len(h5fw['alldata']) :
h5fw['alldata'][row1:row1+dslen,:] = arr_data[:]
else :
h5fw['alldata'].resize( (row1+dslen, cols) )
h5fw['alldata'][row1:row1+dslen,:] = arr_data[:]
row1 += dslen
the python code i ran above ran into a error :
Traceback (most recent call last):
File "C:\Users\J.A.X\Desktop\model\model consept 2\h5 merge.py", line 9, in <module>
arr_data = h5fr[dset1][:]
File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "C:\Users\J.A.X\AppData\Local\Programs\Python\Python36\lib\site-packages\h5py\_hl\group.py", line 288, in __getitem__
oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
File "C:\Users\J.A.X\AppData\Local\Programs\Python\Python36\lib\site-packages\h5py\_hl\base.py", line 200, in _e
name = name.encode('ascii')
AttributeError: 'slice' object has no attribute 'encode'