Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions docs/user_guide/12_evaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,24 @@ DeepForest allows users to assess model performance compared to ground-truth dat
5. mAP - Mean-Average-Precision, a computer vision metric that assesses the performance of the model incoporating precision, recall and average score of true positives. See below.

## Evaluation code

The model's .evaluate method takes a set of labels in the form of a CSV file that includes paths to images and the coordinates of associated labels as well as thresholds to determine if a prediction is close enough to a label to be considered a match.
We can use the trainer.validate method to generate the validation predictions and get the evaluation metrics.

```python
from deepforest import main, get_data
import os
import pandas as pd

m = main.deepforest()
m.load_model("Weecology/deepforest-tree")
# Sample data
csv_file = get_data("OSBS_029.csv")
results = m.evaluate(csv_file, iou_threshold=0.4)
m.config.validation.csv_file = csv_file
m.config.validation.root_dir = os.path.dirname(csv_file)
m.create_trainer()
# Runs validation, logs IoU and overall mAP
m.trainer.validate(m)

# Access predictions dataframe if desired
predictions = pd.concat(m.predictions)
```

This produces a dictionary that contains a detailed result comparison for each label, the aggregate metrics, the predictions data frame, and the ground truth data frame.
Expand All @@ -45,6 +52,8 @@ mAP is the standard COCO evaluation metric and the most common for comparing com

For information on how to calculate mAP, see the [torchmetrics documentation](https://torchmetrics.readthedocs.io/en/stable/detection/mean_average_precision.html) and further reading below.



### Precision and Recall at a set IoU threshold.
This was the original DeepForest metric, set to an IoU of 0.4. This means that all predictions that overlap a ground truth box at IoU > 0.4 are true positives. As opposed to the torchmetrics above, it is intuitive and matches downstream ecological tasks. The drawback is that it is slow, coarse, and does not fully reward the model for having high confidence scores on true positives.

Expand Down
Loading