Shapes3D dataset is not included in the data download script
Also the .npz file listed in https://github.com/google-research/disentanglement_lib/blob/a070670e6589ed45c0b0bd95ea8913e7067eb3ae/disentanglement_lib/data/ground_truth/shapes3d.py#L28
is not to be found anywhere on the web.
Hi,
You can find the Shapes3D dataset on Github linking to here. Save it in your DISENTANGLEMENT_LIB_DATA folder in folder 3dshapes.
To use it in disentanglement_lib, change https://github.com/google-research/disentanglement_lib/blob/a070670e6589ed45c0b0bd95ea8913e7067eb3ae/disentanglement_lib/data/ground_truth/shapes3d.py#L28-L32 to
SHAPES3D_PATH = os.path.join(
os.environ.get("DISENTANGLEMENT_LIB_DATA", "."), "3dshapes", "3dshapes.h5"
)
and https://github.com/google-research/disentanglement_lib/blob/a070670e6589ed45c0b0bd95ea8913e7067eb3ae/disentanglement_lib/data/ground_truth/shapes3d.py#L51-L56 to
with h5py.File(SHAPES3D_PATH, 'r') as dataset:
images = dataset['images'][()]
labels = dataset['labels'][()]
n_samples = images.shape[0]
Hope that helps.
It helps, I have found the .h5 file myself, but it would be convenient if the appropriate changes to the code were included in the repository.
I am using this as a package and would like to avoid editing the code (or creating a fork just for this purpose).
Convert h5py to npz using the following in a python file:
import h5py
import numpy as np
hf = h5py.File('./3dshapes.h5', 'r')
print(hf)
values_to_save = {"images": hf['images'], "labels": hf['labels']}
np.savez('look-at-object-room_floor-hueXwall-hueXobj-hueXobj-sizeXobj-shapeXview-azi.nzp', **values_to_save)
@neonkitchen I think you should resize the saved image array. Because the default implementation of Shapes3D dataset requires to reshape the loaded image when using.
`import h5py import numpy as np
hf = h5py.File('./3dshapes.h5', 'r') print(hf) values_to_save = {"images": hf['images'].reshape([10,10,10,8,4,15,64,64,3]), "labels": hf['labels']} np.savez('look-at-object-room_floor-hueXwall-hueXobj-hueXobj-sizeXobj-shapeXview-azi.nzp', **values_to_save) `