Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrevmatias committed Oct 29, 2020
1 parent 39f9b48 commit 015132a
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 32 deletions.
5 changes: 5 additions & 0 deletions lapixdl/evaluation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Model evaluation module
This module provides evaluation functions and utilities
for segmentation detection and classification models.
"""
37 changes: 35 additions & 2 deletions lapixdl/evaluation/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ def __flat_mask(mask: Mask) -> List[int]:
def evaluate_segmentation(gt_masks: Iterable[Mask],
pred_masks: Iterable[Mask],
classes: List[str]) -> SegmentationMetrics:
"""Evaluates segmentation predictions
The iterables should return one mask per iterations and the itens of
`gt_masks` and `pred_masks` with same index should correspond to the
same sample.
Masks should be 2D arrays where each value corresponds to the class
index of the pixel the sample image.
Args:
gt_masks (Iterable[Mask]): Iterable of ground truth masks.
pred_masks (Iterable[Mask]): Iterable of predicted masks.
classes (List[str]): Class names.
Returns:
SegmentationMetrics: Pixel-based classification and segmentation metrics.
"""

confusion_matrix = np.zeros((len(classes), len(classes)), np.int)

with Counter('Evaluating ') as counter:
Expand All @@ -40,9 +58,24 @@ def evaluate_segmentation(gt_masks: Iterable[Mask],
return metrics


def evaluate_classification(gt_classifications: List[Classification],
pred_classifications: List[Classification],
def evaluate_classification(gt_classifications: Iterable[Classification],
pred_classifications: Iterable[Classification],
classes: List[str]) -> ClassificationMetrics:
"""Evaluates classification predictions
The iterables should return one classification per iterations and
the itens of `gt_classifications` and `pred_classifications` with
same index should correspond to the same sample.
Args:
gt_classifications (Iterable[Classification]): Ground truth classifications.
pred_classifications (Iterable[Classification]): Predicted classifications.
classes (List[str]): Class names.
Returns:
ClassificationMetrics: Classification metrics.
"""

confusion_matrix = np.zeros((len(classes), len(classes)), np.int)

for (curr_gt_classification, curr_pred_classification) in zip(gt_classifications, pred_classifications):
Expand Down
Loading

0 comments on commit 015132a

Please sign in to comment.