I work the save operation under torch environment, not Pytorch.etc. I convert the caption data to .h5 files and then save them by using lua. The key statements are
h5fi = hdf5.open(h5_path, "r")
text_tensor = h5fi:read("char"):all()
img_tensor = h5fi:read("txt"):all()
obj = {char=text_tensor, img=img_path, txt=img_tensor}
torch.save(target_path, obj)
I work the save operation under torch environment, not Pytorch.etc. I convert the caption data to .h5 files and then save them by using lua. The key statements are h5fi = hdf5.open(h5_path, "r") text_tensor = h5fi:read("char"):all() img_tensor = h5fi:read("txt"):all() obj = {char=text_tensor, img=img_path, txt=img_tensor} torch.save(target_path, obj)