Reference for ultralytics/models/yolo/classify/val.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/classify/val.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.models.yolo.classify.val.ClassificationValidator
Bases: BaseValidator
A class extending the BaseValidator class for validation based on a classification model.
Notes
- Torchvision classification models can also be passed to the 'model' argument, i.e. model='resnet18'.
Example
Source code in ultralytics/models/yolo/classify/val.py
build_dataset
Creates and returns a ClassificationDataset instance using given image path and preprocessing parameters.
Source code in ultralytics/models/yolo/classify/val.py
finalize_metrics
Finalizes metrics of the model such as confusion_matrix and speed.
Source code in ultralytics/models/yolo/classify/val.py
get_dataloader
Builds and returns a data loader for classification tasks with given parameters.
Source code in ultralytics/models/yolo/classify/val.py
get_desc
get_stats
Returns a dictionary of metrics obtained by processing targets and predictions.
init_metrics
Initialize confusion matrix, class names, and top-1 and top-5 accuracy.
Source code in ultralytics/models/yolo/classify/val.py
plot_predictions
Plots predicted bounding boxes on input images and saves the result.
Source code in ultralytics/models/yolo/classify/val.py
plot_val_samples
Plot validation image samples.
Source code in ultralytics/models/yolo/classify/val.py
postprocess
preprocess
Preprocesses input batch and returns it.
Source code in ultralytics/models/yolo/classify/val.py
print_results
Prints evaluation metrics for YOLO object detection model.
update_metrics
Updates running metrics with model predictions and batch targets.