Skip to main content

Calculate mAP for CSV format detection result

Project description

Function to calculate mean average precision (mAP) in CSV format for post detection prediction calculation.

Requirements

python 3.*, numpy, pandas, cython(optinal), pyximport(optional)

Installation

pip install CSV-mAP-calculator
pip install CSV-mAP-calculator -i https://pypi.python.org/simple

Usage example:

Path to CSV-files:

from CSV_mAP_calculator import get_csv_mAP

gt_file = 'csvs/gt.csv'
predict_file = 'csvs/predictions.csv'
mean_ap, average_precisions = get_csv_mAP(gt_file, predict_file, iou_threshold=0.5)

Or numpy arrays of shapes (N, 6) and (M, 7).

from CSV_mAP_calculator import get_csv_mAP
import pandas as pd

gt = pd.read_csv('csvs/gt.csv', header=None, names=['img_path', 'x1', 'y1', 'x2', 'y2','conf', 'label']).values
pred = pd.read_csv('csvs/predictions.csv', header=None, names=['img_path', 'x1', 'y1', 'x2', 'y2', 'label']).values
mean_ap, average_precisions = get_csv_mAP(gt, pred)

Input files format

  • Annotation CSV-file:
'img_path','x1','y1','x2','y2','label'
path/imgname1.jpg,0,0,511,511,cat1
path/imgname2.jpg,122,247,666,799,cat2
...
  • Detection CSV-file:
'img_path','x1','y1','x2','y2','conf','label'
path/imgname1.jpg,0,0,511,511,0.8958333,cat1
path/imgname1.jpg,121,32,511,242.5,0.9998,cat2
path/imgname2.jpg,0,0,511,511,0.8958333,cat3
...
  • Return should be like:
Number of files in annotations: 7283
Number of files in predictions: 7282
Unique classes: 3
Detections length: 7282
Annotations length: 7283
cat1                 | 0.917434 |    2445
cat2                 | 0.861768 |    2400
cat3                 | 0.930730 |    2438
mAP: 0.903311
0.903310916116078

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

csv-mAP-calculator-0.1.3.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

csv_mAP_calculator-0.1.3-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page