This repository is no longer being updated. Future development of code tools for geospatial machine learning analysis will be done at https://github.com/cosmiq/solaris.
This package is purpose-built to support evaluation of computer vision models for geospatial imagery. The functionality contained here is used in evaluation of the SpaceNet Challenges.
Several packages require binaries to be installed before pip installing the other packages. Conda is a simple way to install everything and their dependencies:
conda install -c conda-forge cw-eval
You may use pip
to install this package; however, note that one of the dependencies, rtree, can require pre-installation of libspatialindex binaries. This can all be done by installing rtree using conda:
conda install -c conda-forge rtree
or by following the instructions for libspatialindex install.
Once you have dependencies set up, install as usual using pip
:
pip install cw-eval
For bleeding-edge versions (use at your own risk), pip install
from the dev branch of this repository:
pip install --upgrade git+https://github.com/CosmiQ/cw-eval.git@dev
You may also use our Docker container:
docker pull cosmiqworks/cw-eval
See the readthedocs page.
The evaluation metric for this competition is an F1 score with the matching algorithm inspired by Algorithm 2 in the ILSVRC paper applied to the detection of building footprints. For each building there is a geospatially defined polygon label to represent the footprint of the building. A SpaceNet entry will generate polygons to represent proposed building footprints. Each proposed building footprint is either a “true positive” or a “false positive”.
- The proposed footprint is a “true positive” if the proposal is the closest (measured by the IoU) proposal to a labeled polygon AND the IoU between the proposal and the label is about the prescribed threshold of 0.5.
- Otherwise, the proposed footprint is a “false positive”.
There is at most one “true positive” per labeled polygon. The measure of proximity between labeled polygons and proposed polygons is the Jaccard similarity or the “Intersection over Union (IoU)”, defined as:
The value of IoU is between 0 and 1, where closer polygons have higher IoU values.
The F1 score is the harmonic mean of precision and recall, combining the accuracy in the precision measure and the completeness in the recall measure. For this competition, the number of true positives and false positives are aggregated over all of the test imagery and the F1 score is computed from the aggregated counts.
For example, suppose there are N polygon labels for building footprints that are considered ground truth and suppose there are M proposed polygons by an entry in the SpaceNet competition. Let tp denote the number of true positives of the M proposed polygons. The F1 score is calculated as follows:
The F1 score is between 0 and 1, where larger numbers are better scores.
Hints:
- The images provided could contain anywhere from zero to multiple buildings.
- All proposed polygons should be legitimate (they should have an area, they should have points that at least make a triangle instead of a point or a line, etc).
- Use the metric implementation code to self evaluate. To run the metric you can use the following command:
spacenet_eval --help
spacenet_eval --proposal_csv ./TestCases_SpaceNet4/AOI_6_Atlanta_Test_v3_prop_1extra.csv \
--truth_csv ./TestCases_SpaceNet4/AOI_6_Atlanta_Test_v3.csv \
--challenge off-nadir \
--output_file test.csv
All dependencies can be found in the docker file Dockerfile or environment.yml
See LICENSE.