forked from Cartucho/mAP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
260 changed files
with
1,443 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,20 @@ | ||
# mAP | ||
# mAP (mean Average Precision) | ||
|
||
(This code is under construction) | ||
|
||
This code will evaluate the performance of your neural net for object recognition. | ||
The performance will be judged using the mAP criterium defined in the PASCAL VOC 2012 competition. | ||
|
||
### Explanation: | ||
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 a mAP value. A higher mAP value indicates a better performance of your neural net, given your ground-truth. | ||
|
||
##### 1. Calculate AP for each Class | ||
|
||
##### 2. Calculate mAP | ||
|
||
### Usage | ||
|
||
##### Ground-truth | ||
|
||
A separate text file of ground-truth should be generated for each image. In these files, each line should be in the following format: | ||
<class_name> <left> <top> <right> <bottom> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Extra | ||
|
||
### Convert YOLO to PASCAL VOC format: | ||
|
||
1) Add class list to the file `class_list.txt` | ||
2) Run the python script and specify the path as an argument, e.g. `python convert_yolo_format_to_voc.py ../ground-truth` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
bed | ||
person | ||
pictureframe | ||
shirt | ||
lamp | ||
nightstand | ||
clock | ||
heater | ||
windowblind | ||
pillow | ||
robot | ||
cabinetry | ||
door | ||
doorhandle | ||
shelf | ||
pottedplant | ||
chair | ||
diningtable | ||
backpack | ||
whiteboard | ||
cup | ||
tvmonitor | ||
couch_error | ||
coffetable_error | ||
wardrobe | ||
apple | ||
orange | ||
countertop | ||
tap | ||
banana | ||
bicyclehelmet | ||
book | ||
bookcase | ||
refrigerator | ||
wastecontainer | ||
tincan | ||
handbag | ||
sofa | ||
glasses | ||
vase | ||
coffeetable | ||
bowl | ||
remote | ||
candle | ||
bottle | ||
sink | ||
envelope | ||
doll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import sys | ||
import os | ||
import glob | ||
import cv2 | ||
import numpy as np | ||
|
||
# read the class_list.txt to a list | ||
with open("class_list.txt") as f: | ||
obj_list = f.readlines() | ||
## remove whitespace characters like `\n` at the end of each line | ||
obj_list = [x.strip() for x in obj_list] | ||
## e.g. first object in the list | ||
#print(obj_list[0]) | ||
|
||
# change directory to the one with the files to be changed | ||
path_to_folder = sys.argv[1] | ||
#print(path_to_folder) | ||
os.chdir(path_to_folder) | ||
|
||
# old files (YOLO format) will be moved to a new folder (backup/) | ||
## create the backup dir if it doesn't exist already | ||
if not os.path.exists("backup"): | ||
os.makedirs("backup") | ||
|
||
# create VOC format files | ||
for tmp_file in glob.glob('*.txt'): | ||
#print tmp_file | ||
# 1. check that there is an image with that name | ||
## get name before ".txt" | ||
image_name = tmp_file.split(".txt",1)[0] | ||
#print(image_name) | ||
## check if image exists | ||
for fname in os.listdir('../images'): | ||
if fname.startswith(image_name): | ||
## image found | ||
#print(fname) | ||
img = cv2.imread('../images/' + fname) | ||
## get image width and height | ||
img_height, img_width = img.shape[:2] | ||
break | ||
else: | ||
## image not found | ||
print("Error: image not found, corresponding to " + tmp_file) | ||
sys.exit() | ||
# 2. open txt file lines to a list | ||
with open(tmp_file) as f: | ||
content = f.readlines() | ||
## remove whitespace characters like `\n` at the end of each line | ||
content = [x.strip() for x in content] | ||
# 3. move old file (YOLO format) to backup | ||
os.rename(tmp_file, "backup/" + tmp_file) | ||
# 4. create new file (VOC format) | ||
with open(tmp_file, "a") as new_f: | ||
for line in content: | ||
## split a line by spaces. | ||
## "c" stands for center and "n" stands for normalized | ||
obj_id, x_c_n, y_c_n, width_n, height_n = line.split() | ||
obj_name = obj_list[int(obj_id)] | ||
## remove normalization given the size of the image | ||
x_c = float(x_c_n) * img_width | ||
y_c = float(y_c_n) * img_height | ||
width = float(width_n) * img_width | ||
height = float(height_n) * img_height | ||
## compute half width and half height | ||
half_width = width / 2 | ||
half_height = height / 2 | ||
## compute left, top, right, bottom | ||
## in the official VOC challenge the top-left pixel in the image has coordinates (1;1) | ||
left = int(x_c - half_width) + 1 | ||
top = int(y_c - half_height) + 1 | ||
right = int(x_c + half_width) + 1 | ||
bottom = int(y_c + half_height) + 1 | ||
## add new line to file | ||
#print(obj_name + " " + str(left) + " " + str(top) + " " + str(right) + " " + str(bottom)) | ||
new_f.write(obj_name + " " + str(left) + " " + str(top) + " " + str(right) + " " + str(bottom) + '\n') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pictureframe 176 206 225 266 | ||
lamp 335 227 381 305 | ||
heater 170 156 350 240 | ||
pottedplant 272 190 316 259 | ||
book 439 157 556 241 | ||
book 437 246 518 351 | ||
book 515 306 595 375 | ||
book 407 386 531 476 | ||
book 544 419 621 476 | ||
book 609 297 636 392 | ||
coffeetable 172 251 406 476 | ||
coffeetable 2 236 102 395 | ||
tvmonitor 2 10 173 238 | ||
bookcase 395 2 639 470 | ||
glasses 235 289 284 313 | ||
glasses 300 303 344 336 | ||
doll 482 83 515 107 | ||
vase 276 233 304 259 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
pictureframe 247 205 292 265 | ||
lamp 406 230 449 312 | ||
heater 241 157 418 245 | ||
pottedplant 339 192 385 264 | ||
tvmonitor 33 18 242 231 | ||
book 506 254 599 361 | ||
book 514 159 639 251 | ||
book 477 401 592 476 | ||
book 593 330 637 387 | ||
bookcase 464 2 637 473 | ||
glasses 301 292 353 319 | ||
glasses 365 308 413 344 | ||
vase 343 235 368 259 | ||
coffeetable 245 249 483 476 | ||
coffeetable 1 215 172 455 | ||
doll 563 87 597 113 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pottedplant 4 13 79 154 | ||
tvmonitor 93 37 194 121 | ||
shelf 277 2 444 101 | ||
windowblind 469 4 552 91 | ||
coffetable_error 11 152 84 250 | ||
door 516 5 638 410 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
wastecontainer 528 213 602 300 | ||
nightstand 47 115 84 199 | ||
lamp 12 53 29 85 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pottedplant 510 2 633 179 | ||
pictureframe 556 145 636 205 | ||
sofa 11 151 210 476 | ||
coffeetable 495 283 639 475 | ||
pillow 3 145 90 301 | ||
coffeetable 518 177 636 271 | ||
chair 3 79 90 183 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
chair 494 111 562 239 | ||
diningtable 505 103 635 244 | ||
chair 565 142 640 265 | ||
remote 195 313 313 433 | ||
chair 30 97 415 481 | ||
pillow 117 226 338 406 | ||
cup 311 62 330 97 | ||
cabinetry 353 2 629 200 | ||
sofa 146 229 636 481 | ||
cup 328 67 343 90 | ||
tap 291 65 302 88 | ||
cup 603 112 628 130 | ||
shelf 233 1 353 49 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
pottedplant 4 12 297 382 | ||
pottedplant 439 210 540 282 | ||
vase 215 257 252 296 | ||
pictureframe 266 207 397 303 | ||
coffeetable 185 256 530 447 | ||
windowblind 165 4 483 91 | ||
vase 474 260 504 299 | ||
vase 110 341 189 440 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
tvmonitor 1 14 126 147 | ||
pottedplant 476 1 634 448 | ||
tvmonitor 360 31 437 115 | ||
vase 527 356 603 446 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
chair 158 155 291 479 | ||
diningtable 159 155 503 479 | ||
tincan 313 133 352 209 | ||
countertop 3 87 190 263 | ||
cup 91 70 119 98 | ||
sink 3 59 101 102 | ||
orange 378 150 410 179 | ||
banana 398 169 461 194 | ||
apple 427 156 469 183 | ||
cabinetry 181 1 635 272 | ||
cup 258 154 292 190 | ||
cup 288 144 316 177 | ||
tap 3 67 27 94 | ||
chair 163 180 334 468 | ||
chair 359 145 505 407 | ||
chair 192 140 305 388 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
person 158 42 194 65 | ||
bed 2 63 134 215 | ||
wastecontainer 390 228 480 329 | ||
tincan 494 68 538 113 | ||
countertop 461 104 638 350 | ||
tap 571 74 605 110 | ||
person 324 47 352 71 | ||
pillow 2 96 36 114 | ||
pillow 42 94 103 116 | ||
cup 622 73 640 116 | ||
sink 510 102 622 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
door 1 13 156 247 | ||
chair 253 79 402 333 | ||
diningtable 261 112 491 370 | ||
cabinetry 209 4 504 228 | ||
bottle 393 82 442 154 | ||
envelope 358 140 456 167 | ||
cup 316 114 366 149 | ||
doll 433 131 448 164 | ||
doorhandle 5 47 141 101 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
bowl 13 161 106 198 | ||
chair 314 61 410 286 | ||
diningtable 1 125 190 294 | ||
diningtable 301 90 510 302 | ||
chair 1 155 189 479 | ||
door 20 1 189 196 | ||
doorhandle 35 48 181 107 | ||
doll 89 147 112 176 | ||
envelope 377 119 432 138 | ||
cabinetry 237 4 471 188 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
sofa 346 172 625 479 | ||
chair 291 87 421 196 | ||
backpack 468 211 635 316 | ||
backpack 356 129 409 182 | ||
pottedplant 625 92 639 150 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pottedplant 223 4 326 178 | ||
pottedplant 345 130 370 160 | ||
tvmonitor 429 43 640 211 | ||
sofa 4 184 637 461 | ||
remote 351 299 424 341 | ||
pictureframe 279 114 339 161 | ||
candle 481 157 515 204 | ||
backpack 66 209 281 322 | ||
tvmonitor 21 56 107 74 | ||
vase 250 170 278 198 | ||
lamp 341 3 377 90 | ||
windowblind 304 7 432 73 | ||
coffeetable 282 147 376 213 | ||
coffeetable 386 175 611 304 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cabinetry 451 8 639 317 | ||
cup 320 93 390 152 | ||
countertop 1 116 498 479 | ||
bowl 222 113 316 155 | ||
bowl 193 95 268 138 | ||
tap 103 64 174 134 | ||
sink 7 125 379 194 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
shelf 76 1 230 254 | ||
coffeetable 6 156 88 260 | ||
lamp 47 126 72 171 | ||
book 99 197 164 234 | ||
windowblind 204 1 364 82 | ||
wardrobe 372 2 576 233 | ||
door 508 2 578 199 | ||
door 373 2 455 218 | ||
doorhandle 436 67 446 107 | ||
doorhandle 511 66 525 98 | ||
windowblind 600 3 637 84 | ||
whiteboard 581 1 601 70 | ||
book 91 95 144 126 | ||
book 167 107 215 125 | ||
book 169 145 223 175 | ||
book 100 134 136 175 | ||
book 141 157 167 175 | ||
book 168 205 209 229 | ||
pottedplant 3 125 24 167 | ||
glasses 32 166 63 176 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
cup 248 131 292 173 | ||
chair 462 76 557 229 | ||
chair 169 154 358 421 | ||
diningtable 156 139 500 421 | ||
chair 395 153 504 402 | ||
tincan 381 116 412 170 | ||
tincan 354 115 376 177 | ||
diningtable 458 104 635 264 | ||
bowl 290 134 335 152 | ||
door 206 4 290 130 | ||
doorhandle 208 62 294 97 | ||
cabinetry 5 8 175 226 | ||
envelope 511 107 558 128 | ||
doll 577 112 599 133 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
sink 398 139 640 223 | ||
wastecontainer 182 390 335 481 | ||
tap 569 51 634 179 | ||
countertop 319 97 635 481 | ||
person 108 34 144 65 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cabinetry 5 1 635 324 | ||
chair 457 225 635 481 | ||
diningtable 494 208 635 338 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cabinetry 3 1 386 421 | ||
door 376 1 445 259 | ||
doorhandle 374 48 434 111 | ||
cabinetry 480 2 637 228 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
doorhandle 169 1 323 42 | ||
cabinetry 5 2 637 476 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pottedplant 512 17 609 108 | ||
chair 477 75 586 227 | ||
sofa 565 121 640 281 | ||
diningtable 4 95 341 455 | ||
chair 16 149 206 471 | ||
chair 338 92 358 171 | ||
pictureframe 576 107 603 134 | ||
lamp 618 12 640 59 | ||
windowblind 561 4 633 70 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
door 3 1 299 475 | ||
doorhandle 3 1 277 204 |
Oops, something went wrong.