ffcv
ffcv copied to clipboard
ffcv with torch.Tensor
Hi I have a dataset in the form of 'torch.Tensor' and was wondering how to use the DatasetWriter? I am trying to use FFCV for SimCLR, where dataset is torch.utils.data.Dataset, including pairs of augmented images in tensor.
I tried different options like RGBImageFields but this does not work as the inputs are tensors, not images, getting this error TypeError: Unsupported image type <class 'torch.Tensor'>
writer = DatasetWriter(write_path, { 'image': RGBImageField(), # 'image': FloatField(), # 'image':NDArrayField(shape=(2,), dtype=np.dtype('float64')), 'label': IntField() }, num_workers=16)
Hi @rahimentezari ! Sorry for the very late response -- you should use the NDArrayField and convert the torch tensors to numpy arrays with .numpy()
.