Computer Vision
tensoris.backend.metrics.cv ¶
Computer Vision Evaluation Metrics.
Classes¶
MeanIoU ¶
Mean Intersection over Union (mIoU) metric for semantic segmentation.
Formula
where \(TP_c\), \(FP_c\), and \(FN_c\) represent True Positives, False Positives, and False Negatives for class \(c\).
References
Long, J., Shelhamer, E., & Darrell, T. (2015). Fully Convolutional Networks for Semantic Segmentation. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR 2015), pp. 3431-3440. DOI: https://doi.org/10.1109/CVPR.2015.7298965 | arXiv: https://arxiv.org/abs/1411.4038
Source code in src/tensoris/backend/metrics/cv.py
Methods:¶
__init__ ¶
Initialize mIoU metric accumulator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_classes
|
int
|
Total number of semantic categories. |
required |
compute ¶
Compute final mean IoU across all classes.
Returns:
| Type | Description |
|---|---|
Tensor
|
Scalar mIoU score tensor between 0.0 and 1.0. |
Source code in src/tensoris/backend/metrics/cv.py
reset ¶
update ¶
Accumulate confusion matrix for predictions vs targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
Tensor
|
Class predictions tensor of shape (N, H, W) or (N, C, H, W). |
required |
targets
|
Tensor
|
Ground truth class target tensor of shape (N, H, W). |
required |
Source code in src/tensoris/backend/metrics/cv.py
TopKAccuracy ¶
Top-K Classification Accuracy Metric.
Formula
where \(\text{top}_k(\hat{y}_i)\) denotes the \(k\) highest logit prediction indices for sample \(i\).
References
Krizhevsky, A., Sutskever, I., & Hinton, G. E. (2012). ImageNet Classification with Deep Convolutional Neural Networks. Advances in Neural Information Processing Systems (NIPS 2012), pp. 1097-1105.
Source code in src/tensoris/backend/metrics/cv.py
Methods:¶
__call__ ¶
Compute percentage of targets matched within top-K predicted logits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logits
|
Tensor
|
Predicted class probability or logit tensor of shape (N, C). |
required |
targets
|
Tensor
|
Ground truth target indices tensor of shape (N). |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Scalar top-k accuracy score tensor between 0.0 and 1.0. |
Source code in src/tensoris/backend/metrics/cv.py
__init__ ¶
Initialize Top-K accuracy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k
|
int
|
Top k predicted logit indices to match ground truth. |
5
|