docs/macros/validation-args.md
| Argument | Type | Default | Description |
|---|---|---|---|
data | str | None | Specifies the path to the dataset YAML (e.g., coco8.yaml), which should include the path to the validation data. Classification instead takes a dataset directory or a built-in dataset name (e.g., imagenet10). |
imgsz | int | 640 | Defines the size of input images. All images are resized to this dimension before processing. Larger sizes may improve accuracy for small objects but increase computation time. |
batch | int | 16 | Sets the number of images per batch. Higher values utilize GPU memory more efficiently but require more VRAM. Adjust based on available hardware resources. |
save_json | bool | False | If True, saves the results to a JSON file for further analysis, integration with other tools, or submission to evaluation servers like COCO. |
conf | float | 0.001 | Sets the minimum confidence threshold for detections. Lower values increase recall but may introduce more false positives. Precision-recall curves default to 0.001; detection confusion matrices use an explicit conf value, or 0.25 when it is omitted. Summary precision and recall use the max-F1 confidence, so they may differ from values derived from confusion_matrix.png. Defaults to 0.01 for OBB validation to reduce memory usage. |
iou | float | 0.7 | Sets the Intersection Over Union threshold for Non-Maximum Suppression. Controls duplicate detection elimination. |
max_det | int | 300 | Limits the maximum number of detections per image. Useful in dense scenes to prevent excessive detections and manage computational resources. |
quantize | int or str | None | Validation precision: 16/"fp16" enables FP16 validation on supported GPUs; 32/"fp32"/unset is FP32. INT8/PTQ quantization is configured during export, then used by validating the exported model. Replaces the deprecated half flag. |
device | str | None | Specifies the device for validation (cpu, cuda:0, npu, npu:0, etc.). When None, automatically selects the best available device. Multiple CUDA devices can be specified with comma separation. |
dnn | bool | False | If True, uses the OpenCV DNN module for ONNX model inference, offering an alternative to PyTorch inference methods. |
plots | bool | True | When set to True, generates and saves plots of predictions versus ground truth, confusion matrices, and PR curves for visual evaluation of model performance. |
classes | list[int] | None | Specifies a list of class IDs to evaluate. Useful for filtering out and focusing only on certain classes during evaluation. |
rect | bool | True | If True, uses rectangular inference for batching, reducing padding and potentially increasing speed and efficiency by processing images in their original aspect ratio. Ignored for depth validation, which stretches every image to a fixed imgsz square instead of padding. |
split | str | 'val' | Determines the dataset split to use for validation (val, test, or train). Allows flexibility in choosing the data segment for performance evaluation. |
project | str | None | Name of the project directory where validation outputs are saved. Helps organize results from different experiments or models. |
name | str | None | Name of the validation run. Used for creating a subdirectory within the project folder, where validation logs and outputs are stored. |
verbose | bool | True | If True, displays detailed information during the validation process, including per-class metrics, batch progress, and additional debugging information. |
save_txt | bool | False | If True, saves detection results in text files, with one file per image, useful for further analysis, custom post-processing, or integration with other systems. |
save_conf | bool | False | If True, includes confidence values in the saved text files when save_txt is enabled, providing more detailed output for analysis and filtering. |
workers | int | 8 | Number of worker threads for data loading. Higher values can speed up data preprocessing but may increase CPU usage. Setting to 0 uses main thread, which can be more stable in some environments. |
augment | bool | False | Enables test-time augmentation (TTA) during validation, potentially improving detection accuracy at the cost of inference speed by running inference on transformed versions of the input. Only available for Ultralytics PyTorch models. |
agnostic_nms | bool | False | Enables class-agnostic Non-Maximum Suppression, suppressing lower-scoring overlapping boxes regardless of their predicted class. Useful for instance-focused applications. For end-to-end models (YOLO26, YOLOv10), this only prevents the same detection from appearing with multiple class labels (IoU=1.0 duplicates) and does not perform IoU-threshold-based suppression between distinct boxes. |
single_cls | bool | False | Treats all classes as a single class during validation. Useful for evaluating model performance on binary detection tasks or when class distinctions aren't important. |
visualize | bool | False | Visualizes the ground truths, true positives, false positives, and false negatives for each image. Useful for debugging and model interpretation. |
show_labels | bool | True | Displays class labels in validation visualizations when visualize=True. Set to False for a cleaner view of matches and errors. |
show_conf | bool | True | Displays confidence scores in validation visualizations when visualize=True. Set to False for a cleaner view of matches and errors. |
compile | bool or str | False | Enables PyTorch 2.x torch.compile graph compilation with backend='inductor'. Accepts True → "default", False → disables, or a string mode such as "default", "reduce-overhead", "max-autotune-no-cudagraphs". Falls back to eager with a warning if unsupported. |
channels_last | bool | None | Uses the channels_last (NHWC) memory format for native PyTorch validation. None automatically enables it on oneDNN-enabled Linux and Windows x86 CPUs with PyTorch 1.13 or newer, False disables it, and True requests it on supported x86 CPU or CUDA devices. ARM64, MPS, older PyTorch versions, CPUs without oneDNN, and exported formats remain unchanged; validation during training keeps the training model layout. |
end2end | bool | None | Overrides the end-to-end mode in YOLO models that support NMS-free inference (YOLO26, YOLOv10). Setting it to False lets you run validation using the traditional NMS pipeline, additionally allowing you to make use of the iou argument. |