Argument | Type | Default | Description | Explain |
---|---|---|---|---|
data | str | None | Specifies the path to the dataset configuration file (e.g., coco8.yaml). This file includes paths to validation data, class names, and number of classes. | |
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. | 如果为真(True),则将结果保存到一个JSON文件中,以便进行进一步的分析、与其他工具集成,或者提交到诸如COCO这样的评估服务器上。 |
save_hybrid | bool | False | If True, saves a hybrid version of labels that combines original annotations with additional model predictions. Useful for semi-supervised learning and dataset enhancement. | 如果为真(True),则保存一个标签的混合版本,该版本将原始注释与额外的模型预测结果相结合。这对于半监督学习和数据集增强很有用。 |
conf | float | 0.001 | Sets the minimum confidence threshold for detections. Lower values increase recall but may introduce more false positives. Used during validation to compute precision-recall curves. | 设置检测的最小置信度阈值。较低的值会提高召回率,但可能会引入更多的误报。在验证阶段用于计算精确率-召回率曲线。 |
iou | float | 0.6 | Sets the Intersection Over Union threshold for Non-Maximum Suppression. Controls duplicate detection elimination. | 设置非极大值抑制(Non-Maximum Suppression)的交并比(Intersection Over Union,IoU)阈值。该阈值用于控制重复检测的消除。 |
max_det | int | 300 | Limits the maximum number of detections per image. Useful in dense scenes to prevent excessive detections and manage computational resources. | 限制每张图像的最大检测数量。这在密集场景中很有用,可防止出现过多的检测结果,并有效管理计算资源。 |
half | bool | True | Enables half-precision (FP16) computation, reducing memory usage and potentially increasing speed with minimal impact on accuracy. | 启用半精度(FP16)计算,可减少内存使用量,并有可能在对精度影响极小的情况下提高计算速度。 |
device | str | None | Specifies the device for validation (cpu, cuda:0, etc.). When None, automatically selects the best available device. Multiple CUDA devices can be specified with comma separation. | 指定用于验证的设备(如cpu、cuda:0 等等)。当设置为“None”时,会自动选择可用的最佳设备。可以使用逗号分隔来指定多个CUDA设备。 |
dnn | bool | False | If True, uses the OpenCV DNN module for ONNX model inference, offering an alternative to PyTorch inference methods. | 如果设置为真(True),则使用OpenCV的DNN(深度神经网络)模块来进行ONNX模型的推理,这为PyTorch推理方法提供了一种替代方案。 |
plots | bool | False | When set to True, generates and saves plots of predictions versus ground truth, confusion matrices, and PR curves for visual evaluation of model performance.当设置为 True 时,会生成并保存预测结果与真实标签对比图、混淆矩阵以及精确率 - 召回率(PR)曲线,用于对模型性能进行可视化评估。 | |
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. | 如果为真(True),则使用矩形推理进行批量处理,减少填充操作,并且有可能通过按图像的原始宽高比进行处理来提高速度和效率。 |
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. | 确定用于验证的数据集划分部分(验证集(val)、测试集(test)或训练集(train))。在选择用于性能评估的数据部分时提供了灵活性。 |
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 | False | If True, displays detailed information during the validation process, including per-class metrics, batch progress, and additional debugging information. | 如果为真(True),则在验证过程中显示详细信息,包括每类别的指标、批次进度以及额外的调试信息。 |
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. | 如果为真(True),则将检测结果保存到文本文件中,每个图像对应一个文件,这对于进一步分析、自定义后处理或与其他系统集成很有用。 |
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. | 如果为真(True),当启用了保存为文本文件(save_txt)功能时,会在保存的文本文件中包含置信度值,从而为分析和筛选提供更详细的输出内容。 |
save_crop | bool | False | If True, saves cropped images of detected objects, which can be useful for creating focused datasets, visual verification, or further analysis of individual detections. | 如果为真(True),则会保存检测到的对象的裁剪图像,这对于创建聚焦的数据集、进行视觉验证或对单个检测结果进行进一步分析可能会很有用。 |
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. | 在验证期间启用测试时增强(TTA)功能,通过对输入的变换版本运行推理,有可能以牺牲推理速度为代价来提高检测精度。 |
agnostic_nms | bool | False | Enables class-agnostic Non-Maximum Suppression, which merges overlapping boxes regardless of their predicted class. Useful for instance-focused applications. | 启用类别无关的非极大值抑制(Non-Maximum Suppression),该方法会合并重叠的边界框,而不考虑它们预测的类别。这对于关注实例的应用场景很有用。 |
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. |
YOLO中model.val()方法参数解释
于 2025-04-06 20:07:19 首次发布