no appropriate function for conversion path


#1

I find no references on what this error means when code exits the with group:

with h5py.File(image_path, driver='core', backing_store=True, mode='w') as h5image:
	ds = h5image.create_dataset('Images', shape=(rows,width,height,depth), dtype=str(images[0].dtype))
	for cnt, image in enumerate(images):
		ds[cnt:cnt+1,:,:] = image

Error Message:
OSError: Can’t write data (no appropriate function for conversion path)

Stack Trace:
h5py\_objects.pyx:54: in h5py._objects.with_phil.wrapper ??? h5py\_objects.pyx:55: in h5py._objects.with_phil.wrapper ??? ..\art\art-repo\venv\Lib\site-packages\h5py\_hl\dataset.py:708: in __setitem__ self.id.write(mspace, fspace, val, mtype, dxpl=self._dxpl) h5py\_objects.pyx:54: in h5py._objects.with_phil.wrapper ??? h5py\_objects.pyx:55: in h5py._objects.with_phil.wrapper ??? h5py\h5d.pyx:222: in h5py.h5d.DatasetID.write ??? h5py\_proxy.pyx:132: in h5py._proxy.dset_rw ???

Appreciate any help that someone could provide on what is wrong.

Environment:
Windows 10 Pro
Python 3.7.3
h5py 3.1.0
numpy 1.19.1
pandas 1.1.1

Examining the C code in HDF5-1_12_0-alpha0 tag which is the last version prior to the Nov 6, 2020 h5py release I found in H5T.c only one instance of message containing “no appropriate function for conversion path” line 4826:

    if(!path->conv.u.app_func)
    HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "no appropriate function for conversion path")

What I do not understand is why it is looking for a function. The data being written is standard image data at 1080x1080x3 of uint8 data.

Thanks


#2

Hi @john3.16,

What’s the value of str(images[0].dtype)? What are the type and shape of the image variable in the for loop?

Aleksandar


#3

That image type is UINT8

1080 x 1080 x 3


#4

And the ds shape is (rows, 1080, 1080, 3)?

Have you tried ds[cnt:cnt+1,:,:,:] in the assignment?

That conversion path error typically means that for some reason the HDF5 library did not know how to convert between the HDF5 datatypes of the ds and the image values. Your answers imply that ds.dtype and image.dtype should be the same and equivalent to numpy.dtype('uint8'). If so, I think your example code should work.

Aleksandar


#5

Adding that last ,: did the trick. It no longer errors out.

Thought it would store the image but looks more like a grid:


#6

Some how ended up with 4 dimensions instead of 3


#7

Fix the dimensions issue by dropping rows from the shape parm

			with h5py.File(image_path, driver='core', backing_store=True, mode='w') as h5image:
			ds = h5image.create_dataset('Images', shape=(width,height,depth), dtype=str(images[0].dtype))
			for cnt, image in enumerate(images):
				ds[cnt:cnt+1,:,:,:] = image

I thought HDFView would show me the image though.


#8

There is a convention or attributes that must be attached to the dataset in order for hdfview to recognize the dataset as images - are those there.
4 dims indicates there a multiple images. (I think).

allen


#9

What attributes are needed?


#10

Got working with this and I see my images in HDFViewer

		with h5py.File(image_path, driver='core', backing_store=True, mode='w') as h5image:
			for cnt, image in enumerate(images):
				ds = h5image.create_dataset(f'Images_{cnt+1:03}', data=image, dtype=image_dtype, shape=(width,height,depth))

#11

Thanks for the help appreciate it.