

Training the DETR model
You have done most of the heavy lifting in the previous sections, so now you are ready to train your model!
The images in this dataset are still quite large, even after resizing. This means that finetuning this model will
require at least one GPU.
Training involves the following steps:
1. Load the model with [AutoModelForObjectDetection] using the same checkpoint as in the preprocessing.
2. Define your training hyperparameters in [TrainingArguments].
3. Pass the training arguments to [Trainer] along with the model, dataset, image processor, and data collator.
4. Call [~Trainer.train] to finetune your model.
When loading the model from the same checkpoint that you used for the preprocessing, remember to pass the label2id
and id2label maps that you created earlier from the dataset's metadata. Additionally, we specify ignore_mismatched_sizes=True to replace the existing classification head with a new one.