Reference for ultralytics/models/rtdetr/train.py
Note
Full source code for this file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/rtdetr/train.py. Help us fix any issues you see by submitting a Pull Request 🛠️. Thank you 🙏!
ultralytics.models.rtdetr.train.RTDETRTrainer
Bases: DetectionTrainer
A class extending the DetectionTrainer class for training based on an RT-DETR detection model.
Notes
- F.grid_sample used in rt-detr does not support the
deterministic=True
argument. - AMP training can lead to NaN outputs and may produce errors during bipartite graph matching.
Example
Source code in ultralytics/models/rtdetr/train.py
build_dataset(img_path, mode='val', batch=None)
Build RTDETR Dataset
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img_path |
str
|
Path to the folder containing images. |
required |
mode |
str
|
|
'val'
|
batch |
int
|
Size of batches, this is for |
None
|
Source code in ultralytics/models/rtdetr/train.py
get_model(cfg=None, weights=None, verbose=True)
Return a YOLO detection model.
get_validator()
Returns a DetectionValidator for RTDETR model validation.
preprocess_batch(batch)
Preprocesses a batch of images by scaling and converting to float.