This code will evaluate the performance of your neural net for object recognition.
(This code is under construction)
In practice, a higher mAP value indicates a better performance of your neural net, given your ground-truth and set of classes.
The performance of your neural net will be judged using the mAP criterium defined in the PASCAL VOC 2012 competition. We simply adapted the official Matlab code into Python (in our tests they both give the same results).
First (1.), we calculate the Average Precision (AP), for each of the classes present in the ground-truth. Then (2.), we calculate the mean of all the AP's, resulting in an mAP value.
You need to install:
Optional:
- plot the results by installing Matplotlib - Linux, macOS and Windows:
python -mpip install -U pip
python -mpip install -U matplotlib
- show animation by installing OpenCV:
python -mpip install -U pip
python -mpip install -U opencv-python
To start using the mAP you need to clone the repo:
git clone https://github.com/Cartucho/mAP
Step by step:
- Create the ground-truth files
- Move the ground-truth files into the folder ground-truth/
- Create the predicted objects files
- Move the predictions files into the folder predicted/
- Run the code:
python main.py
Optional (if you want to see the animation):
- Insert the images into the folder images/
- Create a separate ground-truth text file for each image.
- Use matching names (e.g. image: "image_1.jpg", ground-truth: "image_1.txt"; "image_2.jpg", "image_2.txt"...).
- In these files, each line should be in the following format:
, where
<class_name> <left> <top> <right> <bottom>
<class_name>
must have no whitespaces between words. - E.g. "image_1.txt":
tvmonitor 2 10 173 238 book 439 157 556 241 book 437 246 518 351 pottedplant 272 190 316 259
- Create a separate predicted objects text file for each image.
- Use matching names (e.g. image: "image_1.jpg", predicted: "image_1.txt"; "image_2.jpg", "image_2.txt"...).
- In these files, each line should be in the following format:
, where
<class_name> <confidence> <left> <top> <right> <bottom>
<class_name>
must have no whitespaces between words. - E.g. "image_1.txt":
tvmonitor 0.471781 0 13 174 244 cup 0.414941 274 226 301 265 book 0.460851 429 219 528 247 chair 0.292345 0 199 88 436 book 0.269833 433 260 506 336
-
João Cartucho - Please give me your feedback: to.cartucho@gmail.com
Feel free to contribute