Version 11.1.1 comes with improved support for the HDFv5 (HDF is an acronym for Hierarchical Data Format) file format. How can I export (and import) the following data into h5 format?
The data I want to export contains both images and lists of lists, here's a minified example:
imgs = ExampleData /@ RandomChoice[ExampleData["TestImage"], 10];
faces = FindFaces /@ imgs;
dummy = <|"images" -> imgs, "faces" -> faces|>
Export["micro-face-dataset.h5", dummy]
Furthermore, I need the data to be written in a standard way so I can access it not only like
Import["micro-face-dataset.h5", {"Datasets", {"/images"}}]
but also from other languages, e.g. python's h5py:
f = h5py.File('micro-face-dataset.h5', 'r')
dataset = f['/images']
Here's a list of subproblems that make this processes tricky:
How can we specify attributes and formats for mixed data types (and encode the images properly, etc.) for export? The docs show examples for import only:
Update
@yode This is definitely possible, see ExampleData/image.h5, one can load it into python:
>>> import h5py, numpy as np
... f = h5py.File('image.h5','r')
... img = np.array(f['image24bitpixel'])
... print img.shape
(149, 227, 3)
It's just a question of how it was created, perhaps with ExportStructuredHDF5[]
in GeneralUtilities.