libffcv / ffcv

FFCV: Fast Forward Computer Vision (and other ML workloads!)
https://ffcv.io
Apache License 2.0
2.79k stars 180 forks source link

FFCV for COCO and Open Image? #282

Closed realliyifei closed 1 year ago

realliyifei commented 1 year ago

Are there FFCV versions of COCO and Open Image (or equivalents) to speed loading and training?

FrancescoSaverioZuppichini commented 1 year ago

+1

andrewilyas commented 1 year ago

These should both be very easy to do in FFCV since all you need is to make a pytorch dataloader and then follow the instructions here! https://docs.ffcv.io/writing_datasets.html

Let us know if you have any questions!

realliyifei commented 1 year ago

Thank you! 

I have a dataset where the images are float datatype after being transformed (as below), but FFCV RGBImageField only supports int8 datatype. Therefore, now I only store the raw un-transformed images to the beton format. May I ask where should I add the image transform in the pipeline with the least impact on the training speed? Or there is another way to let FFCV load the image as float  numpy directly?

train_transform = transforms.Compose([
    transforms.RandomResizedCrop(224),
    CutOut(cutout_factor=0.5),
    transforms.RandomHorizontalFlip(),
    transforms.ToTensor(),
    normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
    ])

Updated: I added to FFCV loader and it works smoothly.

FrancescoSaverioZuppichini commented 1 year ago

@andrewilyas thanks :) I have a question, how does it batch bboxes if for every image there may be a different numbers of bboxes?

andrewilyas commented 1 year ago

I @FrancescoSaverioZuppichini ! FFCV does support variable-length data with BytesField, but generally things will probably be faster if you just pad everything to the maximum number of boundingboxes and use the NDArrayField.

realliyifei commented 1 year ago

yes just a reminder that NDArrayField is not included in the tutorial (last section of here) and it is kinda confusing to lots of first-time users