Code Monkey home page Code Monkey logo

rafaelpadilla / review_object_detection_metrics Goto Github PK

View Code? Open in Web Editor NEW
1.0K 16.0 209.0 38.08 MB

Object Detection Metrics. 14 object detection metrics: mean Average Precision (mAP), Average Recall (AR), Spatio-Temporal Tube Average Precision (STT-AP). This project supports different bounding box formats as in COCO, PASCAL, Imagenet, etc.

License: Other

Makefile 1.76% Python 98.24%
metrics object-detection bounding-boxes pascal-voc pacal-voc-ap coco-dataset coco-api pascal-metrics average-precision mean-average-precision

review_object_detection_metrics's Introduction

Build Status

Citation

This work was published in the Journal Electronics - Special Issue Deep Learning Based Object Detection.

If you use this code for your research, please consider citing:

@Article{electronics10030279,
AUTHOR = {Padilla, Rafael and Passos, Wesley L. and Dias, Thadeu L. B. and Netto, Sergio L. and da Silva, Eduardo A. B.},
TITLE = {A Comparative Analysis of Object Detection Metrics with a Companion Open-Source Toolkit},
JOURNAL = {Electronics},
VOLUME = {10},
YEAR = {2021},
NUMBER = {3},
ARTICLE-NUMBER = {279},
URL = {https://www.mdpi.com/2079-9292/10/3/279},
ISSN = {2079-9292},
DOI = {10.3390/electronics10030279}
}

Download the paper here or here.

Open-Source Visual Interface for Object Detection Metrics

Our previously available tool for object detection assessment has received many positive feedbacks, which motivated us to upgrade it with other metrics and support more bounding box formats. As some external tools, competitions and works are already using the older version, we decided not to modify it but release a newer and more complete project.

The motivation of this project is the lack of consensus used by different works and implementations concerning the evaluation metrics of the object detection problem. Although on-line competitions use their own metrics to evaluate the task of object detection, just some of them offer reference code snippets to calculate the assertiveness of the detected objects. Researchers, who want to evaluate their work using different datasets than those offered by the competitions, need to implement their own version of the metrics or spend a considerable amount of time converting their bounding boxes to formats that are supported by evaluation tools. Sometimes a wrong or different implementation can create different and biased results. Even though many tools have been developed to convert the annotated boxes from one type to another, the quality assessment of the final detections still lacks a tool compatible with different bounding box formats and multiple performance metrics.

Ideally, in order to have trustworthy benchmarking among different approaches, it is necessary to have an implementation that can be used by everyone regardless the dataset used. This work attempts to cover this gap, providing an open-source tool flexible to support many bounding box formats and evaluate detections with different metrics (AP@[.5:.05:.95], AP@50, mAP, AR1, AR10, AR100, etc). We also provide a detailed explanation pointing out their divergences, showing how different implementations may result into different results.

Table of contents

Supported bounding box formats

This implementation does not require modifications of the detection models to match complicated input formats, avoiding conversions to XML, JSON, CSV, or other file types. It supports more than 8 different kinds of annotation formats, including the most popular ones, as presented in the Table below.

Annotation tool Annotation types Output formats
Label me Bounding boxes and polygons Labelme format, but provides conversion to COCO and PASCAL VOC
LabelIMG Bounding boxes PASCAL VOC and YOLO
Microsoft VoTT Bounding boxes and polygons PASCAL VOC, TFRecords, specific CSV, Azure Custom Vision Service, Microsoft Cognitive Toolkit (CNTK), VoTT
Computer Vision Annotation Tool (CVAT) Bounding boxes and polygons COCO, CVAT, Labelme, PASCAL VOC, TFRecord, YOLO, etc
VGG Image Annotation Tool (VIA) Bounding boxes and polygons COCO and specific CSV and JSON

A practical example

Considering the set of 12 images in the figure below:

Each image, except (a), (g), and (j), has at least one target object of the class cat, whose locations are limited by the green rectangles. There is a total of 12 target objects limited by the green boxes. Images (b), (e), and (f) have two ground-truth samples of the target class. An object detector predicted 12 objects represented by the red rectangles (labeled with letters A to L) and their associated confidence levels are represented in percentages. Images (a), (g), and (j) are expected to have no detection. Conversely, images (b), (e), and (f) have two ground-truth bounding boxes.

To evaluate the precision and recall of the 12 detections it is necessary to establish an IOU threshold t, which will classify each detection as TP or FP. In this example, let us first consider as TP the detections with IOU > 50%, that is t=0.5.

As stated before, AP is a metric to evaluate precision and recall in different confidence values. Thus, it is necessary to count the amount of TP and FP classifications given different confidence levels.

By choosing a more restrictive IOU threshold, different precision x recall values can be obtained. The following table computes the precision and recall values with a more strict IOU threshold of t = 0.75. By that, it is noticeable the occurrence of more FP detections, reducing the recall.

Graphical representations of the precision x values presented in both cases t= 0.5 and t=0.75 are shown below:

By comparing both curves, one may note that for this example:

  1. With a less restrictive IOU threshold (t=0.5), higher recall values can be obtained with the highest precision. In other words, the detector can retrieve about 66.5% of the total ground truths without any miss detection.
  2. Using t=0.75, the detector is more sensitive with different confidence values. This is explained by the amount of ups and downs of the curve.
  3. Regardless the IOU threshold applied, this detector can never retrieve 100% of the ground truths (recall = 1). This is due to the fact that the algorithm did not predict any bounding box for one of the ground truths in image (e).

Different methods can be applied to measure the AUC of the precision x recall curve. Considering the N-point interpolation to calculate the AP with N=11, the interpolation measures the recall in the points L=[0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], and considering the All-point interpolation approach, all points are considered. Both approaches result in different plots as shown below:

When an IOU threshold t=0.5 was applied (plots of the first row in image above), the 11-point interpolation method obtained AP=88.64% while the all-point interpolation method improved the results a little, reaching AP=89.58%. Similarly, for an IOU threshold of t=0.75% (plots of the second row in image above), the 11-point interpolation method obtained AP=49.24% and the all-point interpolation AP=50.97%.

In both cases, the all-point interpolation approach considers larger areas above the curve into the summation and consequently obtains higher results. When a lower IOU threshold was considered, the AP was reduced drastically in both interpolation approaches. This is caused by the flexibility the threshold brings in considering TP detections.

Metrics

As each dataset adopts a specific annotation format, works tend to use the evaluation tools provided by the datasets considered to test the performance of their methods, what makes their results dependent to the implemented metric type. PASCAL VOC dataset uses the PASCAL VOC annotation format, which provides a MATLAB evaluation code of the metrics AP and mAP (IOU=.50) hampering other types of metrics to be reported with this dataset. The following table shows that among the listed methods, results are reported using a total of 14 different metrics. Due to the fact that the evaluation metrics are directly associated with the annotation format of the datasets, almost all works report their results using only the metrics implemented by the benchmarking datasets, making such cross-datasets comparative results quite rare in the object detection literature.

Method Benchmark dataset Metrics
CornerNet COCO AP@[.5:.05:.95]; [email protected]; [email protected]; APS; APM; APL
EfficientDet COCO AP@[.5:.05:.95]; [email protected]; [email protected]
Fast R-CNN PASCAL VOC 2007, 2010, 2012 AP; mAP (IOU=.50)
Faster R-CNN PASCAL VOC 2007, 2012 AP; mAP (IOU=.50)
Faster R-CNN COCO AP@[.5:.05:.95]; [email protected]
R-CNN PASCAL VOC 2007, 2010, 2012 AP; mAP (IOU=.50)
RFB Net VOC 2007 mAP (IOU=.50)
RFB Net COCO AP@[.5:.05:.95]; [email protected]; [email protected]; APS; APM; APL
RefineDet VOC 2007, 2012 mAP (IOU=.50)
RefineDet COCO AP@[.5:.05:.95]; [email protected]; [email protected]; APS; APM; APL
RetinaNet COCO AP@[.5:.05:.95]; [email protected]; [email protected]; APS; APM; APL
R-FCN VOC 2007, 2012 mAP (IOU=.50)
R-FCN COCO AP@[.5:.05:.95];[email protected]; APS; APM; APL
SSD VOC 2007, 2012 mAP (IOU=.50)
SSD COCO AP@[.5:.05:.95]; [email protected]; [email protected]; APS; APM; APL; AR1; AR10; AR100; ARS; ARM; ARL
SSD ImageNet mAP (IOU=.50)
Yolo v1 PASCAL VOC 2007, 2012; Picasso; People-Art AP; mAP (IOU=.50)
Yolo v2 PASCAL VOC 2007, 2012 AP; mAP (IOU=.50)
Yolo v2 COCO AP@[.5:.05:.95]; [email protected]; [email protected]; APS; APM; APL; AR1; AR10; AR100; ARS; ARM; ARL
Yolo v3 COCO AP@[.5:.05:.95]; [email protected]; [email protected]; APS; APM; APL; AR1; AR10; AR100; ARS; ARM; ARL
Yolo v4 COCO AP@[.5:.05:.95]; [email protected]; [email protected]; APS; APM; APL
Yolo v5 COCO AP@[.5:.05:.95]; [email protected]

As previously presented, there are different ways to evaluate the area under the precision x recall and recall x IOU curves. Nonetheless, besides the combinations of different IOU thresholds and interpolation points, other considerations are also applied resulting in different metric values. Some methods limit the evaluation by object scales and detections per image. Such variations are computed and named differently as shown below:

AP with IOU Threshold t=0.5

This AP metric is widely used to evaluate detections in the PASCAL VOC dataset. It measures the AP of each class individually by computing the area under the precision x recall curve interpolating all points. In order to classify detections as TP or FP the IOU threshold is set to t=0.5.

mAP with IOU Threshold t=0.5

This metric is also used by PASCAL VOC dataset and is calculated as the AP with IOU t=0.5, but the result obtained by each class is averaged.

These two metrics evaluate the precision x curve differently than the PASCAL VOC metrics. In this method, the interpolation is performed in N=101 recall points. Then, the computed results for each class are summed up and divided by the number of classes.

The only difference between [email protected] and [email protected] is the applied IOU thresholds. [email protected] uses t=0.5 whereas [email protected] applies t=0.75. These metrics are commonly used to report detectAPS, APM and APLions performed in the COCO dataset.

AP@[.5:.05:.95]

This metric expands the [email protected] and [email protected] metrics by computing the AP@ with ten different IOU thresholds (t=[0.5, 0.55, ..., 0.95]) and taking the average among all computed results.

APS, APM and APL

These three metrics, also referred to as AP Across Scales, apply the AP@[.5,.05:.95] taking into consideration the size of the ground-truth object. APS only evaluates the ground-truth objects of small sizes (area < 32^2 pixels); APM considers only ground-truth objects of medium sizes (32^2 < area < 96^2 pixels); APL considers large ground-truth objects (area > 96^2) only.

When evaluating objects of a given size, objects of the other sizes (both ground-truth and predicted) are not considered in the evaluation. This metric is also part of the COCO evaluation dataset.

Spatio-Temporal Tube Average Precision (STT-AP)

When dealing with videos, one may be interested in evaluating the model performance at video level, i.e., whether the object was detected in the video as a whole. This metric is an extension of the AP metric that integrates spatial and temporal localizations; it is concise, yet expressive. A spatio-temporal tube To of an object o is the spatio-temporal region defined as the concatenation of the bounding boxes of an object from each frame of a video, that is T_o = [Bo,q Bo,q+1 ... Bo,q+Q-1, where Bo,k is the bounding box of the object o in frame k of the video that is constituted of Q frames indexed by k= q, q+1,..., q+Q-1. Considering a ground-truth spatio-temporal tube Tgt and a predicted spatio-temporal tube Tp, the spatio-temporal tube IOU (STT-IOU) measures the ratio of the overlapping to the union of the "discrete volume" between Tgt and Tp, as illustrated bellow:

Based on these definitions, the proposed STT-AP metric follows the AP.

How to use this project

Requirements

We highly suggest you to create an anaconda environment using the environment.yml file available in this repository. To create the environment and install all necessary packages, run the following command:

conda env create -n <env_name> --file environment.yml

Now activate the evironment: conda activate <env_name>

Install the tool: python setup.py install

Run the UI: python run.py

Running

Images

To help users to apply different metrics using multiple bounding box formats, a GUI was created to facilitate the evaluation process. By running the command python run.py, the following screen will show:

Each number in red represents a funcionality described below:

  1. Annotations: Select the folder containing the ground-truth annotation file(s).
  2. Images: Select the folder containing the images. This is only necessary if your ground-truth file contains formats in relative coordinates and to visualize the images (see item 5).
  3. Classes: YOLO (.txt) training format represents the classes with IDs (sequential integers). For this annotation type, you need to inform a txt file listing one class per line. The first line refers to the class with id 0, the second line is the class with id 1, and so on. See here an example of file used to represent classes of the VOC PASCAL dataset.
  4. Coordinate formats: Choose the format of the annotations file(s).
  5. Ground-truth statistics: This is an optional feature that provides the amount of bounding boxes of each ground-truth class and to visualize the images with bounding boxes. To access this option, you must have selected the images (see item 2).
  6. Annotations: Select the folder containing the annotation file(s) with your detections.
  7. Classes: If your coordinats formats represent the classes with IDs (sequential integers), you need to inform a text file listing one class per line. The first line refers to the class with id 0, the second line is the class with id 1, and so on. See here an example of file used to represent classes of the VOC PASCAL dataset.
  8. Coordinate formats: Choose the format of the files used to represent the the detections.
  9. Detections statistics: This is an optional feature that provides the amount of detections per class. You can also visualize the quality of the detections by plotting the detected and ground-truth boxes on the images.
  10. Metrics: Select at least one metric to evaluate your detections. For the PASCAL VOC AP and mAP, you can choose different IOUs. Note that the default IOU threshold used in the PASCAL VOC AP metric is 0.5.
  11. Output: Choose a folder where PASCAL VOC AP plots will be saved.
  12. RUN: Run the metrics. Depending on the amount of your dataset and the format of your detections, it may take a while. Detections in relative coordinates usually take a little longer to read than other formats.

Visualize the statistics of your dataset (Options #5 and #9: Ground-truth and detection statistics) to make sure you have chosen the right formats. If somehow the formats are incorrect the boxes are going to appear incorreclty on the images.

You can also save the images and plot a bar plot with the distribution of the boxes per class.

Spatio-Temporal Tube

Ground-truth Format

For annotation with STT, use a .json file following format:

{
"videos": [
  {
    "id": int,
    "file_name": str,
    "width": int,
    "height": int
  }
]

"annotations": [
  {
    "id": int,
    "video_id": int,
    "category_id": int,
    "track":[
      {
        "frame": int,
        "bbox": [x ,y , width, height],
        "confidence": float
      }
    ]
  }]

"categories": [
  {
    "id": int,
    "name": str
  }
]
}
Predictions Format

For detection with STT, use a .json file following format:

[
  {
    "id": int,
    "video_id": int,
    "category_id": int,
    "track":[
      {
        "frame": int,
        "bbox": [x ,y , width, height],
        "confidence": float
      }
    ]
  }
]

See example annotation and example predictions for examples of annotation and prediction .json files.

Running
from src.evaluators.tube_evaluator import TubeEvaluator

tube_evaluator = TubeEvaluator(annot_filepath, preds_filepath)
res, mAP = tube_evaluator.evaluate(thr=0.5)

Contributing

We appreciate all contributions. If you are planning to contribute with this repository, please do so without any further discussion.

If you plan to add new features, support other bounding box formats, create tutorials, please first open an issue and discuss the feature with us. If you send a PR without previous discussion, it might be rejected.

It is also important that for each new feature, supporting other bounding box formats, and metrics, a pytest must be created.

review_object_detection_metrics's People

Contributors

denguir avatar f-fl0 avatar kuluum avatar rafaelpadilla avatar thadeuluiz avatar wesleylp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

review_object_detection_metrics's Issues

More convenient Python usage

Hi all, thank you for this great tool.

I am using the code here from Python (need to test and compare a model trained in various scenarios) and would like to see some improvements around the usage from code.
I can do the code changes around most of this but wanted to make sure it is welcome here in the current community, as they might change a lot of existing code.

The changes that jumped into mind:

  • Renaming the main package name from src to some more useful name
  • Publishing as a pip package
  • Building a documentation site from sources
  • Not opening a plotly window right on import (from src.evaluators.coco_evaluator import get_coco_summary makes a window to show)

Is there any interest besides me in such king of changes?

Plotting results with fixed Y- and X-axis values

Hi,
is there any way to make the plots axis limited to a fixed value? (e.g. always show axis from 0 to 1)
This would make comparing different results with each other easier.
Thanks for any help in advance.

Output summary table?

Is there any way to print tables with columns for image_frame, TP, FP for all classes in the ground truth like a summary report? I need to make a comparison based on the number of TP and FP detections for all the classes and need to know in which image_frame the FP occurred.

Difference between calculated metrics in comparison to pycocotools

Hi,

I have compared the pycocotools PythonAPI and this tool. Following are the results I found for my object detection model

Pycocotools

Running per image evaluation...
Evaluate annotation type *bbox*
DONE (t=0.00s).
Accumulating evaluation results...
DONE (t=0.00s).
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.640
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.880
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.880
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.692
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = -1.000
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.690
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.690
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.690
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.690
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000

This Tool

COCO METRICS:
AP: 0.6927034910485187
AP50: 0.9877452861565228
AP75: 0.9499113594946688
APsmall: nan
APmedium: nan
APlarge: 0.6927034910485187
AR1: 0.7631782945736434
AR10: 0.7631782945736434
AR100: 0.7631782945736434
ARsmall: nan
ARmedium: nan
ARlarge: 0.7631782945736434

PASCAL METRIC (AP per class)
MRZ: 0.9950323498187128

PASCAL METRIC (mAP)
mAP: 0.9950323498187128

Has anyone else encountered this? or care to comment.

[Bug] Coordinates for XYWH and XYX2Y2 swaped when type_coordinates == CoordinatesType.RELATIVE

Hi, thanks for the tool!

I think the condition to set the coordinates for relative bounding boxes are swaped:

from src.bounding_box import BoundingBox

# a GT bbox with relative coordinates in the XYWH format
bbox = BoundingBox(
    "img_filename",
    "category_class",
    (
        0.04287003610108303,
        0.04801829268292683,
        0.22021660649819497,
        0.11178861788617887,
    ),
    CoordinatesType.RELATIVE,
    (540, 960),
    None,
    BBType.GROUND_TRUTH,
    BBFormat.XYWH,
)

print(bbox)

>>> image name: img_filename
class: category_class
bb (XYWH): (-36.0, -8.0, 119.0, 108.0)
bb (X1Y1X2Y2): (-36.0, -8.0, 83.0, 100.0)
area: 13080.0
bb_type: None

If I change it to the XYX2Y2 format:

# a GT bbox with relative coordinates in the XYWH format
bbox = BoundingBox(
    "img_filename",
    "category_class",
    (
        0.04287003610108303,
        0.04801829268292683,
        0.22021660649819497,
        0.11178861788617887,
    ),
    CoordinatesType.RELATIVE,
    (540, 960),
    None,
    BBType.GROUND_TRUTH,
    BBFormat.XYX2Y2,
)

print(bbox)

>>> image name: img_filename
class: category_class
bb (XYWH): (23.0, 46.0, 96.0, 61.0)
bb (X1Y1X2Y2): (23.0, 46.0, 119.0, 107.0)
area: 6014.0
bb_type: None

Provide example of use with command line interface

Hello
I'm having issues with PyQt5 on my current system and the push buttons for file selection don't work properly, meaning that the navigation bar doesn't pop up and I cannot load the annotations or gt files.

Could you please add an example on how to use this new version of the library using CLI? Just like in the previous release of this tool.

Big thanks!

RuntimeWarning: Mean of empty slice. RuntimeWarning: invalid value encountered in double_scalars

The error message is


(metrics) maged-ubuntu-20@magedubuntu20-virtual-machine:~/Desktop/PyCharm_Projects/16_metrics_measurement$ python run.py
/home/maged-ubuntu-20/anaconda3/envs/metrics/lib/python3.9/site-packages/numpy/core/fromnumeric.py:3372: RuntimeWarning: Mean of empty slice.
  return _methods._mean(a, axis=axis, dtype=dtype,
/home/maged-ubuntu-20/anaconda3/envs/metrics/lib/python3.9/site-packages/numpy/core/_methods.py:170: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
/home/maged-ubuntu-20/anaconda3/envs/metrics/lib/python3.9/site-packages/numpy/core/fromnumeric.py:3372: RuntimeWarning: Mean of empty slice.
  return _methods._mean(a, axis=axis, dtype=dtype,
/home/maged-ubuntu-20/anaconda3/envs/metrics/lib/python3.9/site-packages/numpy/core/_methods.py:170: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
/home/maged-ubuntu-20/anaconda3/envs/metrics/lib/python3.9/site-packages/numpy/core/fromnumeric.py:3372: RuntimeWarning: Mean of empty slice.
  return _methods._mean(a, axis=axis, dtype=dtype,
/home/maged-ubuntu-20/anaconda3/envs/metrics/lib/python3.9/site-packages/numpy/core/_methods.py:170: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)

Here is my ground truth file

0 412 130 95 104
0 521 82 126 106
0 521 314 226 155
0 820 372 123 101
0 473 616 101 120
0 956 350 98 105
0 177 581 110 88
0 680 638 125 120
0 958 611 135 113

Here is my predicted truth file

0 0.99 699 1012 778 1079
0 0.99 529 1014 591 1079
0 0.99 0 997 77 1079
0 0.99 77 1003 251 1079
0 0.99 367 1027 454 1079
0 0.99 1458 975 1579 1077
0 0.99 1274 882 1425 1038
0 0.99 952 925 1056 1033
0 0.99 500 978 554 1026
0 0.99 1788 952 1865 1021
0 0.99 733 913 877 1004
0 0.99 196 901 305 998
0 0.99 1840 870 1919 965

As you can see all accuracy score is zero

Screenshot from 2021-03-09 20-45-59

Can someone please help with how to fix this issue?

mAP shows zero when having absolute values as ground truth and left top right bottom as prediction

Here is the .txt ground truth

0 880 291 74 105
0 1001 288 73 99
0 1108 282 103 84
0 1284 330 108 94
0 1531 466 62 71
0 1337 518 85 91
0 1456 732 81 71
0 1163 664 73 82
0 1030 692 91 88
0 1036 602 91 82
0 1065 426 88 84
0 898 620 64 100
0 839 721 56 81
0 770 694 56 111
0 680 466 68 77
0 414 302 68 93
0 322 382 76 82
0 457 564 79 81
0 362 469 87 71
0 570 568 88 88
0 577 472 90 77

Here is the predicted

0 1 1124 711 1225 807
0 1 892 647 984 769
0 1 492 700 553 751
0 1 974 574 1081 700
0 1 1332 599 1399 678
0 1 631 510 706 607
0 1 977 384 1091 477
0 1 693 307 830 462
0 1 1149 407 1217 458
0 1 1341 323 1460 435
0 1 379 368 437 429
0 1 359 270 450 363
0 1 1463 276 1533 349

Here is with the plot that it shows zero, can someone please suggest why is mAP zero when some are overlapping?

Screenshot from 2021-03-11 18-45-18

Detection statistics window crashes - possible cause = adding annotation containing FP?

I can successfully generate 1 detection box for 1 image but when I try to add another image to my detections folder which contains 2 detections in the image the GUI crashes and closes.
Is it because of the FP picked up in the 2nd image?

Here are my images:
100000003
100000005

ground truth:
100000003.txt
100000005.txt
(2nd image has 1 labelled object)
detections:
100000003.txt
100000005.txt
(2nd image has 2 detections, one with very low confidence.)

class names:
hrsc2016_class_lev2.txt

Bounding box not displayed correctly when using absolute values

I'm using the following bounding box co-ordinates:

class_id, xmin, ymin, xmax, ymax (absolute)
0 288 330 985 694
100000003.txt

When I view this ground truth label in the GUI it's not displayed correctly:

image

If I use the YOLO format co-ordinates it does display correctly:

class_id, centre X, centre Y, width, height (relative)
0 0.5594664998900839 0.6356930616425305 0.6354730515252976 0.4891887385670732

image

Here's my image:

100000003

Please can you help me to understand why this is occurring and advise how I can fix this? (if it's a bug)

Tool crashes because of metadata files in the annotations folder

Issue:
When I provided a folder path which has absolute annotations files (.txt), tool also trying to read metadata file ".DS_Store" (macOS) present in the same folder. This crashing the GUI tool.

Suggestion for fixing: Validate the file extension before accessing/reading.

Unable to resize GUI

When I launch the GUI I'm unable to resize it to fit my screen resolution. I only have the capability to minimize or maximise the window. What this means is I'm unable to see the lower section of the window containing the detail needed for metrics.
Please can this issue be fixed somehow? (without having to change the screen resolution settings on my laptop)

"no file was found in the selected detection format in the annotations directory" while trying to show detection statistics

Hi.
I've been trying to find the mAP score for my dataset using this tool, but it can't find the detection annotations. I'm following the format specified:
<class_name> <confidence> <left> <top> <right> <bottom>

image

My Dataset has two classes, 'person' and 'vehicle' and I've listed them in the aider-classes.txt as per VOC format.

Here is a sample file in my detections annotation directory:

person 0.9996482 224 69 248 116 
person 0.9983903 212 160 231 202 
person 0.7466929 241 89 252 117 
vehicle 0.9925392 103 133 163 236 

The environment setup is all as per the environment.yml file provided. It loads the ground truths correctly but fails to identify the detections annotations.

Could you please help me investigate this?

5.4.0-72-generic #80~18.04.1-Ubuntu

Absolute Values Ground Truth

The default format for ground truth absolute values is XYWH (ret = converter.text2bb(self.dir_annotations_gt, bb_type=BBType.GROUND_TRUTH)).

Since this is not documented anywhere I had to look at the code to try and find why my GT bounding boxes were not matching.

Ideally there should be two format options for Absolute Values, XYWH and XYX2Y2.

Error when validating absolute coordinates

Hi Devs!

I think there is an issue when validating that coordinates are absolute. Currently when having absolute but not integer coordinates the validation fails.

The issue seems to happen here. Coordinates are checked to be integers instead of absolute values. Changing int to abs should fix this.

Confusion matrix implementation

Hello @rafaelpadilla,

first thanks for this repo, it's been very useful! However, for my work I needed to compute confusion matrices to understand better why my model was not performing better on some classes. I saw that on the "old repo", there were two issues related to that (https://github.com/rafaelpadilla/Object-Detection-Metrics/issues?q=confusion+matrix) but no implementation has been done.
Given that I implemented a function to compute confusion matrix based on your repo, would you be interested if I implement this as a new feature in this repo?
I based the logic of my function on that article https://towardsdatascience.com/confusion-matrix-in-object-detection-with-tensorflow-b9640a927285

See below the logic of the algorithm
Screenshot 2021-05-31 at 11 12 00 AM

Let me know,

Benoit

Exclude ‚difficult‘ objects from VOC mAP

Thanks for the great tool! However, when I evaluate on VOC, it includes objects marked as difficult in the evaluation. That leads to an unwanted decrease in mAP. Is there a built-in way to exclude these objects from the ground truth and the predictions?

Detections format <class name> <confidence> <left><top><right><bottom> pruducing error

If I choose class name confidence left top right bottom (ABSOLUTE) pruducing error as coordinates format for Detections and I want to show the detection statistics, I always get the UI error: "No file was found for the seleted detection format in the annotations directory" and python warning: "Image not found in the directory None. It is required to get its dimensions"

Does anyone know how to fix this issue?

How to make PR curve monotonically decreasing

Hii, Thank you so much for this, saved me a ton of time!

I have an issue with the Pascal VOC implementation:
I was reading the Pascal VOC 2012 doc which defines AP like,

image

I was wondering why the outputs are not monotonically decreasing when I run this code?

image

Program Crashing

Hi!

I have labels and detections that I am using with YOLO. Once I load all of the annotations for groundtruth and detections to the GUI and click "Run", the program crashes.

My issue might be related to the .txt files that I am using, this is an example of one of my .txt files for one of my images:

Example from a .txt file in the groundtruth folder(generated from LabelImg tool):
2 0.771250 0.220000 0.350000 0.335000

Example from a .txt file in the detection folder(generated from darknet detector):
1 0.2522 0.1515 0.2163 0.3143
0 0.6483 0.6727 0.8530 0.4814

I have a classes.txt file that I have also loaded

This is the output from terminal:

Traceback (most recent call last):
File "/Users/zaraadamou/review_object_detection_metrics/src/ui/run_ui.py", line 312, in btn_run_clicked
det_annotations, passed = self.load_annotations_det()
File "/Users/zaraadamou/review_object_detection_metrics/src/ui/run_ui.py", line 154, in load_annotations_det
ret = converter.text2bb(self.dir_dets,
File "/Users/zaraadamou/review_object_detection_metrics/src/utils/converter.py", line 257, in text2bb
if bb_type == BBType.DETECTED and not validations.is_relative_text_format(
File "/Users/zaraadamou/review_object_detection_metrics/src/utils/validations.py", line 369, in is_relative_text_format
if not is_empty_file(file_path):
File "/Users/zaraadamou/review_object_detection_metrics/src/utils/validations.py", line 542, in is_empty_file
for line in f:
File "/Users/zaraadamou/opt/anaconda3/envs/objmetrics/lib/python3.9/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc9 in position 99: invalid continuation byte
zsh: abort python run.py

-Zara

Tool crashes when yolo is selected

Hi,

I found an error here:

ret = self.yolo2bb(self.dir_annotations_gt,

I think it should be convert.yolo2bb.

f'Warning: Class id represented in the {filepath_classes_det} is not in the range of classes specified in the file {file_obj_names}.'

This line threw an error too because of the file_obj_name.

I got also a problem with my own data.
When using 7 0.94 0.475215 0.524656 0.884800 0.873787 from one of your toyexamples for relativ coordinates the detection gets counted. But if i use my own data which looks like this 0 0.74 0.271635 0.153846 0.687500 0.427885 there are no detections at all. The groundtruth looks like this: 0 0.1466346153846154 0.4230769230769231 0.09134615384615384 0.08173076923076923 and gets recognized perfectly. Is there a reason for this?

Display class name with confidence score on detection

I understand how it is possible to add the class name to the detection box, but is it possible to add both the class name and confidence score?
Even better would be a colour-coded detection box to distinguish between a True Positive and a False Positive.

Is it possible to have a FP and FN at the same time?

The green box is the ground truth and the red the predicted box. If I set the iou threshold to 0.5 I would consider this prediction as a bad prediction, so it would be a FP. But as the ground truth is not detected would it count as well as a FN?

I mean does this count as FP, or as a FP and FN?

image

Thank you.

What is yolo (.txt) format?

I try to use the program while having YOLO-like text annotations per image in the following format.

Ground truth annotations:

6 0.4435201401050788 0.6020274689339438 0.059544658493870466 0.14061478090255072
8 0.36646234676007006 0.18999345977763243 0.05341506129597193 0.13276651406147807
10 0.36274080560420313 0.289404839764552 0.05647985989492113 0.17593198168737742
7 0.1725043782837128 0.36527141922825374 0.08231173380035027 0.20078482668410727
11 0.2539404553415061 0.7432962720732506 0.06917688266199651 0.1366906474820143
11 0.20556042031523644 0.05493786788750817 0.06348511383537656 0.10987573577501634

Predictions:

6.0 0.9641061425209045 0.7914067506790161 0.36787542700767517 0.07676965743303299 0.20017971098423004
2.0 0.9538318514823914 0.4433167576789856 0.3955462872982025 0.0672389417886734 0.14360184967517853
3.0 0.9517371654510498 0.6636454463005066 0.14527581632137299 0.050998225808143616 0.11069779098033905
8.0 0.9489786028862 0.5190893411636353 0.3004150092601776 0.049637917429208755 0.10972640663385391
3.0 0.9478994607925415 0.6771969199180603 0.2292448729276657 0.05333113670349121 0.10690070688724518
3.0 0.9314520955085754 0.699550211429596 0.40322744846343994 0.05508119612932205 0.11604183167219162

when having the file structure:

images
   a.jpg
   b.jpg
   c.jpg
annotations
   a.txt
   b.txt
   c.txt
predicted_labels
   a.txt
   b.txt
   c.txt

However, I have the following error: No file was found for the selected detection format in the annotations directory.
What goes wrong?

Coordinates format for Gt: (*)YOLO (.txt)
Coordinates format for Detections: <class_id> <x_center> <y_center> (REL)

(By the way, why images are expected for evaluating labels only?)

Unable to resize image viewer window

Once the ground-truth or detection statistics viewer is displayed I'm unable to resize it either by maximizing or dragging with the cursor. The image window is quite small which makes things difficult to see when objects, bounding boxes and labels are small or clustered together.
Please would it be possible to add the capability to resize this window and collapse the statistics box?

OKS metric support

Is there a possibility to add OKS metrics to this? I can write the code and submit a PR is that's acceptable

Unrecognized selector sent to instance 0x7f8f8579a940 on Mac

Hi
I found no result output after pressing the "run" button.
In the terminal it outputs "[QNSApplication macMinorVersion]: unrecognized selector sent to instance 0x7f8f8579a940" .
I' m running this application on Mac os.
Hope get your help, thanks!

COCO results format not accepted

The results format as specified by COCO cannot be parsed.
[{
"image_id": int, "category_id": int, "bbox": [x,y,width,height], "score": float,
}]

Throws error:
(vendor-eval) C:\Vendor evaluation2\review_object_detection_metrics>python run.py
Traceback (most recent call last):
File "C:\Vendor evaluation2\review_object_detection_metrics\src\ui\run_ui.py", line 258, in btn_statistics_det_clicked
det_annotations, passed = self.load_annotations_det()
File "C:\Vendor evaluation2\review_object_detection_metrics\src\ui\run_ui.py", line 115, in load_annotations_det
ret = converter.coco2bb(self.dir_dets, bb_type=BBType.DETECTED)
File "C:\Vendor evaluation2\review_object_detection_metrics\src\utils\converter.py", line 31, in coco2bb
if not validations.is_coco_format(file_path):
File "C:\Vendor evaluation2\review_object_detection_metrics\src\utils\validations.py", line 302, in is_coco_format
return is_json(file_path) and json_contains_tags(file_path, [
File "C:\Vendor evaluation2\review_object_detection_metrics\src\utils\validations.py", line 115, in json_contains_tags
for key, item in json_object.items():
AttributeError: 'list' object has no attribute 'items'

Packaging as pip modules

As per rafaelpadilla/Object-Detection-Metrics#58, it would be great if this could be published as a pip module on PyPi so that people had a consistent, reliable, trustworthy way to generate metrics for their object detection results. It looks like it is already mostly compatible as there is a skeleton setup.py, so hopefully it isn't too difficult. I don't know what restructuring may be required to avoid naming collisions with other packages.

While the repo is now called "review_object_detection_metrics", I think import object_detection_metrics is still a sensible name for the package.

I don't know whether @andreydung or @malpunek would still be interested in helping with this new version.

UI interface issues in Windows 10 #help_needed

Hi @rafaelpadilla Sir,
Hope you are fine. Sir i would like to know you that i am using your project and i am facing trouble with the your projects UI interface in windows 10 (64 bit), as i am not not able to resize, close or minimize the UI interface; its freezing as it is appearing on my windows screen. And i am assuming some related warning showing up on command prompt which i tried to solve but failed.
Here i am giving you some screenshot of my command prompt and windows screen.
Hoping to hear you soon...
Thanks in advance!

Command Prompt ::

cmd

Windows Screen ::

win_interface

invalid image directory

Hi

I have loaded ground truth labels as pascal VOC (xml) and their images and it successfully plotted them (on show ground truth statics). I also made my detection labels as the toyexample for classid confidence left top height width (absolute) as below:
0 0.99 37 143 98 206
and I just simply gave the directory of all detections. however, the GUI give the error of "For the selected annotation type, it is necessary to inform a directory with the dataset images. Directory is empty or does not have valid images."

So I just copied all the images (as the ones I gave in first part) to the detection labels directory. But it still give me the mentioned error. My images are 300*300 png frames.

Thanks for support.

It's much too Slow!

I tested it with 6500 images, it works fine.
But when the number of images comes to more than ten thousnads, the program crash!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.