I mean, I loaded a dataset, this dataset has length 40000+, and dataset [ i ] [ 0 ] is a PIL image, their sizes vary, like (480, 640), (537, 450). dataset [ i ] [ 1 ] is a tuple containing tuple containing some dictionaries. Every dictionary represent an annotation for an object in this picture, denote this dictionary as dict. dict [ ‘bbox’ ] is a list [ x, y, width, height ] which represents the bounding box, and dict [ ‘category_id’ ] is an int representing the object’s  category.
What I want is to get some images with size (416, 416), this size fits my network. And the [ ‘bbox’ ] value should be processed simultaneously as I changed the size of picture.
The solution I take now is to process these images and annotations during training time. Well, I find it slow to load data ( a tensor of batch size 32 : (32, 3, 416, 416). Loading this tensor with its annotation takes about 3 seconds )
Previously I tried to changes the value of bbox coordinates before training, It would takes about 4 hours to process 40000+ images’ annotations. I didn’t stand to wait for so long time…