The example you referred to is demonstrating "inference", where a pre-trained model (fasterrcnn_resnet50_fpn_v2) is used to detect objects in a single image (grace_hopper_517x606.jpg).
However, if your goal is to further train a pre-trained model using your own dataset (e.g., a folder of labeled images), this process is called transfer learning.
To do this, you would:
Wrap your image dataset using a custom Dataset class (e.g., by subclassing torch.utils.data.Dataset).
Pass it to a DataLoader to efficiently load batches of data.
Feed the data into the model and train it using the standard PyTorch training loop.