Reference for ultralytics/models/rtdetr/val.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/rtdetr/val.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.models.rtdetr.val.RTDETRDataset
Bases: YOLODataset
Real-Time DEtection and TRacking (RT-DETR) dataset class extending the base YOLODataset class.
This specialized dataset class is designed for use with the RT-DETR object detection model and is optimized for real-time detection and tracking tasks.
This constructor sets up a dataset specifically optimized for the RT-DETR (Real-Time DEtection and TRacking) model, building upon the base YOLODataset functionality.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
Any
|
Variable length argument list passed to the parent YOLODataset class. |
()
|
data
|
Dict | None
|
Dictionary containing dataset information. If None, default values will be used. |
None
|
**kwargs
|
Any
|
Additional keyword arguments passed to the parent YOLODataset class. |
{}
|
Source code in ultralytics/models/rtdetr/val.py
build_transforms
Build transformation pipeline for the dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hyp
|
dict
|
Hyperparameters for transformations. |
None
|
Returns:
Type | Description |
---|---|
Compose
|
Composition of transformation functions. |
Source code in ultralytics/models/rtdetr/val.py
load_image
Load one image from dataset index 'i'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
i
|
int
|
Index of the image to load. |
required |
rect_mode
|
bool
|
Whether to use rectangular mode for batch inference. |
False
|
Returns:
Name | Type | Description |
---|---|---|
im |
ndarray
|
The loaded image. |
resized_hw |
tuple
|
Height and width of the resized image with shape (2,). |
Examples:
Source code in ultralytics/models/rtdetr/val.py
ultralytics.models.rtdetr.val.RTDETRValidator
Bases: DetectionValidator
RTDETRValidator extends the DetectionValidator class to provide validation capabilities specifically tailored for the RT-DETR (Real-Time DETR) object detection model.
The class allows building of an RTDETR-specific dataset for validation, applies Non-maximum suppression for post-processing, and updates evaluation metrics accordingly.
Examples:
>>> from ultralytics.models.rtdetr import RTDETRValidator
>>> args = dict(model="rtdetr-l.pt", data="coco8.yaml")
>>> validator = RTDETRValidator(args=args)
>>> validator()
Note
For further details on the attributes and methods, refer to the parent DetectionValidator class.
Source code in ultralytics/models/yolo/detect/val.py
build_dataset
Build an 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
|
Returns:
Type | Description |
---|---|
RTDETRDataset
|
Dataset configured for RT-DETR validation. |
Source code in ultralytics/models/rtdetr/val.py
postprocess
Apply Non-maximum suppression to prediction outputs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
preds
|
List | Tuple | Tensor
|
Raw predictions from the model. |
required |
Returns:
Type | Description |
---|---|
List[Tensor]
|
List of processed predictions for each image in batch. |