""" Use this code to unpack the h5 file to pickle files to be able to use the original preprocessing pipeline. """ import h5py import pickle from pathlib import Path def unpack_h5(h5_path, out_dir="v1"): out = Path(out_dir) out.mkdir(exist_ok=True) with h5py.File(h5_path, "r") as f: for key in f.keys(): g = f[key] d = {name: ds[:] for name, ds in g.items()} d["meta"] = dict(g.attrs) with open(out / f"{key}.pkl", "wb") as fp: pickle.dump(d, fp) print(f"Saved {len(list(out.glob('*.pkl')))} files to {out}/") h5_file = "autorois_dataset_v1.h5" unpack_h5(h5_file, out_dir="v1")