Closed sa-cloud closed 1 year ago
It works when not passing in the transformation
Sorry for seeing this late! The RGBImageField you want to use in the ffcv writer requires a PIL Image to be passed in, not a torch tensor. Your original dataset keeps the images in PIL Image form but your torchvision pipeline includes a conversion to tensor, hence why the write only works without the torchvision transform. For your task, try shortening the torchvision transform to only including RandomResizedCrop and RandomHorizontalFlip. If you still need to normalize the image, you can normalize during ffcv loading by including the NormalizeImage operation in your image pipeline during loading:
https://docs.ffcv.io/_modules/ffcv/transforms/normalize.html#NormalizeImage
Furthermore, if you want to do all of the torchvision transforms in ffcv instead, RandomResizedCrop and RandomHorizontalFlip are actually both available in ffcv:
https://docs.ffcv.io/_modules/ffcv/transforms/random_resized_crop.html#RandomResizedCrop
https://docs.ffcv.io/_modules/ffcv/transforms/flip.html#RandomHorizontalFlip
I tried to convert the torchvision dataset datasets.Places365 to ffcv format and got an exception:
I ran the following lines: