Reference for ultralytics/models/yolo/classify/val.py
Note
Full source code for this file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/classify/val.py. Help us fix any issues you see by submitting 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
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
__init__(dataloader=None, save_dir=None, pbar=None, args=None, _callbacks=None)
Initializes ClassificationValidator instance with args, dataloader, save_dir, and progress bar.
Source code in ultralytics/models/yolo/classify/val.py
finalize_metrics(*args, **kwargs)
Finalizes metrics of the model such as confusion_matrix and speed.
Source code in ultralytics/models/yolo/classify/val.py
get_dataloader(dataset_path, batch_size)
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(model)
Initialize confusion matrix, class names, and top-1 and top-5 accuracy.
Source code in ultralytics/models/yolo/classify/val.py
plot_predictions(batch, preds, ni)
Plots predicted bounding boxes on input images and saves the result.
Source code in ultralytics/models/yolo/classify/val.py
plot_val_samples(batch, ni)
Plot validation image samples.
Source code in ultralytics/models/yolo/classify/val.py
preprocess(batch)
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(preds, batch)
Updates running metrics with model predictions and batch targets.