Reference for ultralytics/utils/metrics.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/metrics.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.utils.metrics.ConfusionMatrix
A class for calculating and updating a confusion matrix for object detection and classification tasks.
Attributes:
Name | Type | Description |
---|---|---|
task |
str
|
The type of task, either 'detect' or 'classify'. |
matrix |
ndarray
|
The confusion matrix, with dimensions depending on the task. |
nc |
int
|
The number of classes. |
conf |
float
|
The confidence threshold for detections. |
iou_thres |
float
|
The Intersection over Union threshold. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nc
|
int
|
Number of classes. |
required |
conf
|
float
|
Confidence threshold for detections. |
0.25
|
iou_thres
|
float
|
IoU threshold for matching detections to ground truth. |
0.45
|
task
|
str
|
Type of task, either 'detect' or 'classify'. |
'detect'
|
Source code in ultralytics/utils/metrics.py
matrix
plot
Plot the confusion matrix using seaborn and save it to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
normalize
|
bool
|
Whether to normalize the confusion matrix. |
True
|
save_dir
|
str
|
Directory where the plot will be saved. |
''
|
names
|
tuple
|
Names of classes, used as labels on the plot. |
()
|
on_plot
|
func
|
An optional callback to pass plots path and data when they are rendered. |
None
|
Source code in ultralytics/utils/metrics.py
print
process_batch
Update confusion matrix for object detection task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
detections
|
Array[N, 6] | Array[N, 7]
|
Detected bounding boxes and their associated information.
Each row should contain (x1, y1, x2, y2, conf, class)
or with an additional element |
required |
gt_bboxes
|
Array[M, 4] | Array[N, 5]
|
Ground truth bounding boxes with xyxy/xyxyr format. |
required |
gt_cls
|
Array[M]
|
The class labels. |
required |
Source code in ultralytics/utils/metrics.py
process_cls_preds
Update confusion matrix for classification task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
preds
|
Array[N, min(nc, 5)]
|
Predicted class labels. |
required |
targets
|
Array[N, 1]
|
Ground truth class labels. |
required |
Source code in ultralytics/utils/metrics.py
tp_fp
Return true positives and false positives.
Returns:
Type | Description |
---|---|
tuple
|
True positives and false positives. |
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.Metric
Bases: SimpleClass
Class for computing evaluation metrics for YOLOv8 model.
Attributes:
Name | Type | Description |
---|---|---|
p |
list
|
Precision for each class. Shape: (nc,). |
r |
list
|
Recall for each class. Shape: (nc,). |
f1 |
list
|
F1 score for each class. Shape: (nc,). |
all_ap |
list
|
AP scores for all classes and all IoU thresholds. Shape: (nc, 10). |
ap_class_index |
list
|
Index of class for each AP score. Shape: (nc,). |
nc |
int
|
Number of classes. |
Methods:
Name | Description |
---|---|
ap50 |
AP at IoU threshold of 0.5 for all classes. Returns: List of AP scores. Shape: (nc,) or []. |
ap |
AP at IoU thresholds from 0.5 to 0.95 for all classes. Returns: List of AP scores. Shape: (nc,) or []. |
mp |
Mean precision of all classes. Returns: Float. |
mr |
Mean recall of all classes. Returns: Float. |
map50 |
Mean AP at IoU threshold of 0.5 for all classes. Returns: Float. |
map75 |
Mean AP at IoU threshold of 0.75 for all classes. Returns: Float. |
map |
Mean AP at IoU thresholds from 0.5 to 0.95 for all classes. Returns: Float. |
mean_results |
Mean of results, returns mp, mr, map50, map. |
class_result |
Class-aware result, returns p[i], r[i], ap50[i], ap[i]. |
maps |
mAP of each class. Returns: Array of mAP scores, shape: (nc,). |
fitness |
Model fitness as a weighted combination of metrics. Returns: Float. |
update |
Update metric attributes with new evaluation results. |
Source code in ultralytics/utils/metrics.py
ap
property
Return the Average Precision (AP) at an IoU threshold of 0.5-0.95 for all classes.
Returns:
Type | Description |
---|---|
(ndarray, list)
|
Array of shape (nc,) with AP50-95 values per class, or an empty list if not available. |
ap50
property
Return the Average Precision (AP) at an IoU threshold of 0.5 for all classes.
Returns:
Type | Description |
---|---|
(ndarray, list)
|
Array of shape (nc,) with AP50 values per class, or an empty list if not available. |
curves_results
property
Return a list of curves for accessing specific metrics curves.
map
property
Return the mean Average Precision (mAP) over IoU thresholds of 0.5 - 0.95 in steps of 0.05.
Returns:
Type | Description |
---|---|
float
|
The mAP over IoU thresholds of 0.5 - 0.95 in steps of 0.05. |
map50
property
Return the mean Average Precision (mAP) at an IoU threshold of 0.5.
Returns:
Type | Description |
---|---|
float
|
The mAP at an IoU threshold of 0.5. |
map75
property
Return the mean Average Precision (mAP) at an IoU threshold of 0.75.
Returns:
Type | Description |
---|---|
float
|
The mAP at an IoU threshold of 0.75. |
mp
property
Return the Mean Precision of all classes.
Returns:
Type | Description |
---|---|
float
|
The mean precision of all classes. |
mr
property
Return the Mean Recall of all classes.
Returns:
Type | Description |
---|---|
float
|
The mean recall of all classes. |
class_result
fitness
Return model fitness as a weighted combination of metrics.
mean_results
update
Update the evaluation metrics with a new set of results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results
|
tuple
|
A tuple containing evaluation metrics: - p (list): Precision for each class. - r (list): Recall for each class. - f1 (list): F1 score for each class. - all_ap (list): AP scores for all classes and all IoU thresholds. - ap_class_index (list): Index of class for each AP score. - p_curve (list): Precision curve for each class. - r_curve (list): Recall curve for each class. - f1_curve (list): F1 curve for each class. - px (list): X values for the curves. - prec_values (list): Precision values for each class. |
required |
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.DetMetrics
Bases: SimpleClass
Utility class for computing detection metrics such as precision, recall, and mean average precision (mAP).
Attributes:
Name | Type | Description |
---|---|---|
save_dir |
Path
|
A path to the directory where the output plots will be saved. |
plot |
bool
|
A flag that indicates whether to plot precision-recall curves for each class. |
names |
dict
|
A dictionary of class names. |
box |
Metric
|
An instance of the Metric class for storing detection results. |
speed |
dict
|
A dictionary for storing execution times of different parts of the detection process. |
task |
str
|
The task type, set to 'detect'. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
save_dir
|
Path
|
Directory to save plots. |
Path('.')
|
plot
|
bool
|
Whether to plot precision-recall curves. |
False
|
names
|
dict
|
Dictionary mapping class indices to names. |
{}
|
Source code in ultralytics/utils/metrics.py
curves_results
property
Return dictionary of computed performance metrics and statistics.
results_dict
property
Return dictionary of computed performance metrics and statistics.
class_result
Return the result of evaluating the performance of an object detection model on a specific class.
mean_results
process
Process predicted results for object detection and update metrics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tp
|
ndarray
|
True positive array. |
required |
conf
|
ndarray
|
Confidence array. |
required |
pred_cls
|
ndarray
|
Predicted class indices array. |
required |
target_cls
|
ndarray
|
Target class indices array. |
required |
on_plot
|
callable
|
Function to call after plots are generated. |
None
|
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.SegmentMetrics
Bases: SimpleClass
Calculates and aggregates detection and segmentation metrics over a given set of classes.
Attributes:
Name | Type | Description |
---|---|---|
save_dir |
Path
|
Path to the directory where the output plots should be saved. |
plot |
bool
|
Whether to save the detection and segmentation plots. |
names |
dict
|
Dictionary of class names. |
box |
Metric
|
An instance of the Metric class to calculate box detection metrics. |
seg |
Metric
|
An instance of the Metric class to calculate mask segmentation metrics. |
speed |
dict
|
Dictionary to store the time taken in different phases of inference. |
task |
str
|
The task type, set to 'segment'. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
save_dir
|
Path
|
Directory to save plots. |
Path('.')
|
plot
|
bool
|
Whether to plot precision-recall curves. |
False
|
names
|
dict
|
Dictionary mapping class indices to names. |
()
|
Source code in ultralytics/utils/metrics.py
ap_class_index
property
Return the class indices.
Boxes and masks have the same ap_class_index.
curves_results
property
Return dictionary of computed performance metrics and statistics.
class_result
mean_results
process
Process the detection and segmentation metrics over the given set of predictions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tp
|
ndarray
|
True positive array for boxes. |
required |
tp_m
|
ndarray
|
True positive array for masks. |
required |
conf
|
ndarray
|
Confidence array. |
required |
pred_cls
|
ndarray
|
Predicted class indices array. |
required |
target_cls
|
ndarray
|
Target class indices array. |
required |
on_plot
|
callable
|
Function to call after plots are generated. |
None
|
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.PoseMetrics
Bases: SegmentMetrics
Calculates and aggregates detection and pose metrics over a given set of classes.
Attributes:
Name | Type | Description |
---|---|---|
save_dir |
Path
|
Path to the directory where the output plots should be saved. |
plot |
bool
|
Whether to save the detection and pose plots. |
names |
dict
|
Dictionary of class names. |
box |
Metric
|
An instance of the Metric class to calculate box detection metrics. |
pose |
Metric
|
An instance of the Metric class to calculate pose metrics. |
speed |
dict
|
Dictionary to store the time taken in different phases of inference. |
task |
str
|
The task type, set to 'pose'. |
Methods:
Name | Description |
---|---|
process |
Processes metrics over the given set of predictions. |
mean_results |
Returns the mean of the detection and segmentation metrics over all the classes. |
class_result |
Returns the detection and segmentation metrics of class |
maps |
Returns the mean Average Precision (mAP) scores for IoU thresholds ranging from 0.50 to 0.95. |
fitness |
Returns the fitness scores, which are a single weighted combination of metrics. |
ap_class_index |
Returns the list of indices of classes used to compute Average Precision (AP). |
results_dict |
Returns the dictionary containing all the detection and segmentation metrics and fitness score. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
save_dir
|
Path
|
Directory to save plots. |
Path('.')
|
plot
|
bool
|
Whether to plot precision-recall curves. |
False
|
names
|
dict
|
Dictionary mapping class indices to names. |
()
|
Source code in ultralytics/utils/metrics.py
curves_results
property
Return dictionary of computed performance metrics and statistics.
maps
property
Return the mean average precision (mAP) per class for both box and pose detections.
class_result
mean_results
process
Process the detection and pose metrics over the given set of predictions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tp
|
ndarray
|
True positive array for boxes. |
required |
tp_p
|
ndarray
|
True positive array for keypoints. |
required |
conf
|
ndarray
|
Confidence array. |
required |
pred_cls
|
ndarray
|
Predicted class indices array. |
required |
target_cls
|
ndarray
|
Target class indices array. |
required |
on_plot
|
callable
|
Function to call after plots are generated. |
None
|
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.ClassifyMetrics
Bases: SimpleClass
Class for computing classification metrics including top-1 and top-5 accuracy.
Attributes:
Name | Type | Description |
---|---|---|
top1 |
float
|
The top-1 accuracy. |
top5 |
float
|
The top-5 accuracy. |
speed |
dict
|
A dictionary containing the time taken for each step in the pipeline. |
task |
str
|
The task type, set to 'classify'. |
Source code in ultralytics/utils/metrics.py
curves_results
property
Return a list of curves for accessing specific metrics curves.
results_dict
property
Return a dictionary with model's performance metrics and fitness score.
process
Process target classes and predicted classes to compute metrics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
targets
|
Tensor
|
Target classes. |
required |
pred
|
Tensor
|
Predicted classes. |
required |
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.OBBMetrics
Bases: SimpleClass
Metrics for evaluating oriented bounding box (OBB) detection.
Attributes:
Name | Type | Description |
---|---|---|
save_dir |
Path
|
Path to the directory where the output plots should be saved. |
plot |
bool
|
Whether to save the detection plots. |
names |
dict
|
Dictionary of class names. |
box |
Metric
|
An instance of the Metric class for storing detection results. |
speed |
dict
|
A dictionary for storing execution times of different parts of the detection process. |
References
Parameters:
Name | Type | Description | Default |
---|---|---|---|
save_dir
|
Path
|
Directory to save plots. |
Path('.')
|
plot
|
bool
|
Whether to plot precision-recall curves. |
False
|
names
|
dict
|
Dictionary mapping class indices to names. |
()
|
Source code in ultralytics/utils/metrics.py
curves_results
property
Return a list of curves for accessing specific metrics curves.
results_dict
property
Return dictionary of computed performance metrics and statistics.
class_result
Return the result of evaluating the performance of an object detection model on a specific class.
mean_results
process
Process predicted results for object detection and update metrics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tp
|
ndarray
|
True positive array. |
required |
conf
|
ndarray
|
Confidence array. |
required |
pred_cls
|
ndarray
|
Predicted class indices array. |
required |
target_cls
|
ndarray
|
Target class indices array. |
required |
on_plot
|
callable
|
Function to call after plots are generated. |
None
|
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.bbox_ioa
Calculate the intersection over box2 area given box1 and box2. Boxes are in x1y1x2y2 format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
box1
|
ndarray
|
A numpy array of shape (n, 4) representing n bounding boxes. |
required |
box2
|
ndarray
|
A numpy array of shape (m, 4) representing m bounding boxes. |
required |
iou
|
bool
|
Calculate the standard IoU if True else return inter_area/box2_area. |
False
|
eps
|
float
|
A small value to avoid division by zero. |
1e-07
|
Returns:
Type | Description |
---|---|
ndarray
|
A numpy array of shape (n, m) representing the intersection over box2 area. |
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.box_iou
Calculate intersection-over-union (IoU) of boxes. Both sets of boxes are expected to be in (x1, y1, x2, y2) format. Based on https://github.com/pytorch/vision/blob/master/torchvision/ops/boxes.py.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
box1
|
Tensor
|
A tensor of shape (N, 4) representing N bounding boxes. |
required |
box2
|
Tensor
|
A tensor of shape (M, 4) representing M bounding boxes. |
required |
eps
|
float
|
A small value to avoid division by zero. |
1e-07
|
Returns:
Type | Description |
---|---|
Tensor
|
An NxM tensor containing the pairwise IoU values for every element in box1 and box2. |
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.bbox_iou
Calculate the Intersection over Union (IoU) between bounding boxes.
This function supports various shapes for box1
and box2
as long as the last dimension is 4.
For instance, you may pass tensors shaped like (4,), (N, 4), (B, N, 4), or (B, N, 1, 4).
Internally, the code will split the last dimension into (x, y, w, h) if xywh=True
,
or (x1, y1, x2, y2) if xywh=False
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
box1
|
Tensor
|
A tensor representing one or more bounding boxes, with the last dimension being 4. |
required |
box2
|
Tensor
|
A tensor representing one or more bounding boxes, with the last dimension being 4. |
required |
xywh
|
bool
|
If True, input boxes are in (x, y, w, h) format. If False, input boxes are in (x1, y1, x2, y2) format. |
True
|
GIoU
|
bool
|
If True, calculate Generalized IoU. |
False
|
DIoU
|
bool
|
If True, calculate Distance IoU. |
False
|
CIoU
|
bool
|
If True, calculate Complete IoU. |
False
|
eps
|
float
|
A small value to avoid division by zero. |
1e-07
|
Returns:
Type | Description |
---|---|
Tensor
|
IoU, GIoU, DIoU, or CIoU values depending on the specified flags. |
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.mask_iou
Calculate masks IoU.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask1
|
Tensor
|
A tensor of shape (N, n) where N is the number of ground truth objects and n is the product of image width and height. |
required |
mask2
|
Tensor
|
A tensor of shape (M, n) where M is the number of predicted objects and n is the product of image width and height. |
required |
eps
|
float
|
A small value to avoid division by zero. |
1e-07
|
Returns:
Type | Description |
---|---|
Tensor
|
A tensor of shape (N, M) representing masks IoU. |
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.kpt_iou
Calculate Object Keypoint Similarity (OKS).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kpt1
|
Tensor
|
A tensor of shape (N, 17, 3) representing ground truth keypoints. |
required |
kpt2
|
Tensor
|
A tensor of shape (M, 17, 3) representing predicted keypoints. |
required |
area
|
Tensor
|
A tensor of shape (N,) representing areas from ground truth. |
required |
sigma
|
list
|
A list containing 17 values representing keypoint scales. |
required |
eps
|
float
|
A small value to avoid division by zero. |
1e-07
|
Returns:
Type | Description |
---|---|
Tensor
|
A tensor of shape (N, M) representing keypoint similarities. |
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics._get_covariance_matrix
Generate covariance matrix from oriented bounding boxes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
boxes
|
Tensor
|
A tensor of shape (N, 5) representing rotated bounding boxes, with xywhr format. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
Covariance matrices corresponding to original rotated bounding boxes. |
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.probiou
Calculate probabilistic IoU between oriented bounding boxes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obb1
|
Tensor
|
Ground truth OBBs, shape (N, 5), format xywhr. |
required |
obb2
|
Tensor
|
Predicted OBBs, shape (N, 5), format xywhr. |
required |
CIoU
|
bool
|
If True, calculate CIoU. |
False
|
eps
|
float
|
Small value to avoid division by zero. |
1e-07
|
Returns:
Type | Description |
---|---|
Tensor
|
OBB similarities, shape (N,). |
Notes
- OBB format: [center_x, center_y, width, height, rotation_angle].
- Implements the algorithm from https://arxiv.org/pdf/2106.06072v1.pdf.
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.batch_probiou
Calculate the probabilistic IoU between oriented bounding boxes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obb1
|
Tensor | ndarray
|
A tensor of shape (N, 5) representing ground truth obbs, with xywhr format. |
required |
obb2
|
Tensor | ndarray
|
A tensor of shape (M, 5) representing predicted obbs, with xywhr format. |
required |
eps
|
float
|
A small value to avoid division by zero. |
1e-07
|
Returns:
Type | Description |
---|---|
Tensor
|
A tensor of shape (N, M) representing obb similarities. |
References
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.smooth_bce
Compute smoothed positive and negative Binary Cross-Entropy targets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
eps
|
float
|
The epsilon value for label smoothing. |
0.1
|
Returns:
Type | Description |
---|---|
tuple
|
A tuple containing the positive and negative label smoothing BCE targets. |
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.smooth
Box filter of fraction f.
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.plot_pr_curve
Plot precision-recall curve.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
px
|
ndarray
|
X values for the PR curve. |
required |
py
|
ndarray
|
Y values for the PR curve. |
required |
ap
|
ndarray
|
Average precision values. |
required |
save_dir
|
Path
|
Path to save the plot. |
Path('pr_curve.png')
|
names
|
dict
|
Dictionary mapping class indices to class names. |
{}
|
on_plot
|
callable
|
Function to call after plot is saved. |
None
|
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.plot_mc_curve
plot_mc_curve(
px,
py,
save_dir=Path("mc_curve.png"),
names={},
xlabel="Confidence",
ylabel="Metric",
on_plot=None,
)
Plot metric-confidence curve.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
px
|
ndarray
|
X values for the metric-confidence curve. |
required |
py
|
ndarray
|
Y values for the metric-confidence curve. |
required |
save_dir
|
Path
|
Path to save the plot. |
Path('mc_curve.png')
|
names
|
dict
|
Dictionary mapping class indices to class names. |
{}
|
xlabel
|
str
|
X-axis label. |
'Confidence'
|
ylabel
|
str
|
Y-axis label. |
'Metric'
|
on_plot
|
callable
|
Function to call after plot is saved. |
None
|
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.compute_ap
Compute the average precision (AP) given the recall and precision curves.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
recall
|
list
|
The recall curve. |
required |
precision
|
list
|
The precision curve. |
required |
Returns:
Type | Description |
---|---|
float
|
Average precision. |
ndarray
|
Precision envelope curve. |
ndarray
|
Modified recall curve with sentinel values added at the beginning and end. |
Source code in ultralytics/utils/metrics.py
ultralytics.utils.metrics.ap_per_class
ap_per_class(
tp,
conf,
pred_cls,
target_cls,
plot=False,
on_plot=None,
save_dir=Path(),
names={},
eps=1e-16,
prefix="",
)
Compute the average precision per class for object detection evaluation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tp
|
ndarray
|
Binary array indicating whether the detection is correct (True) or not (False). |
required |
conf
|
ndarray
|
Array of confidence scores of the detections. |
required |
pred_cls
|
ndarray
|
Array of predicted classes of the detections. |
required |
target_cls
|
ndarray
|
Array of true classes of the detections. |
required |
plot
|
bool
|
Whether to plot PR curves or not. |
False
|
on_plot
|
func
|
A callback to pass plots path and data when they are rendered. |
None
|
save_dir
|
Path
|
Directory to save the PR curves. |
Path()
|
names
|
dict
|
Dict of class names to plot PR curves. |
{}
|
eps
|
float
|
A small value to avoid division by zero. |
1e-16
|
prefix
|
str
|
A prefix string for saving the plot files. |
''
|
Returns:
Name | Type | Description |
---|---|---|
tp |
ndarray
|
True positive counts at threshold given by max F1 metric for each class. |
fp |
ndarray
|
False positive counts at threshold given by max F1 metric for each class. |
p |
ndarray
|
Precision values at threshold given by max F1 metric for each class. |
r |
ndarray
|
Recall values at threshold given by max F1 metric for each class. |
f1 |
ndarray
|
F1-score values at threshold given by max F1 metric for each class. |
ap |
ndarray
|
Average precision for each class at different IoU thresholds. |
unique_classes |
ndarray
|
An array of unique classes that have data. |
p_curve |
ndarray
|
Precision curves for each class. |
r_curve |
ndarray
|
Recall curves for each class. |
f1_curve |
ndarray
|
F1-score curves for each class. |
x |
ndarray
|
X-axis values for the curves. |
prec_values |
ndarray
|
Precision values at mAP@0.5 for each class. |
Source code in ultralytics/utils/metrics.py
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
|