AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.58k stars 7.95k forks source link

`detector valid` generates all "image_id" is 0 #5615

Open lazerliu opened 4 years ago

lazerliu commented 4 years ago

Dear Alexey, First of all, thank you for your great work.

I've used validto generate coco_results.json,but I got all the image_idis 0,my results like this:

[
...
{"image_id":0, "category_id":1, "bbox":[629.906372, 93.858353, 18.401489, 16.803741], "score":0.113654},
{"image_id":0, "category_id":1, "bbox":[140.943192, 342.924347, 20.169861, 30.018188], "score":0.089187},
{"image_id":0, "category_id":1, "bbox":[624.000000, 97.106476, 24.103394, 21.146072], "score":0.033187},
{"image_id":0, "category_id":1, "bbox":[144.488617, 355.852173, 17.576019, 17.879456], "score":0.018196},
{"image_id":0, "category_id":1, "bbox":[621.957886, 113.128845, 25.458862, 33.240417], "score":0.005647},
{"image_id":0, "category_id":1, "bbox":[612.411011, 99.263046, 10.962769, 17.111465], "score":0.004837},
{"image_id":0, "category_id":1, "bbox":[633.184082, 97.726295, 21.925049, 19.070374], "score":0.003713},
{"image_id":0, "category_id":1, "bbox":[618.204102, 92.849335, 17.411987, 18.312973], "score":0.002731},
{"image_id":0, "category_id":1, "bbox":[617.733582, 90.278694, 44.910400, 23.889359], "score":0.002378},
{"image_id":0, "category_id":1, "bbox":[603.124878, 89.683998, 11.797363, 12.185028], "score":0.002228},
{"image_id":0, "category_id":1, "bbox":[0.000000, 29.954353, 4.645081, 26.263885], "score":0.002055},
{"image_id":0, "category_id":1, "bbox":[0.000000, 20.163948, 3.774524, 19.243519], "score":0.001632},
{"image_id":0, "category_id":1, "bbox":[137.526642, 339.686676, 16.503113, 25.850891], "score":0.001602},
{"image_id":0, "category_id":1, "bbox":[647.096008, 25.978762, 22.297729, 25.604887], "score":0.001168},
{"image_id":0, "category_id":1, "bbox":[90.852844, 366.714111, 19.151260, 25.072632], "score":0.001075},
{"image_id":0, "category_id":1, "bbox":[655.136353, 0.000000, 23.170166, 6.582273], "score":0.001035}
]

and my test.txt like this

/home/xxx/documents/gits/alexab/darknet/build/darknet/x64/data/obj/test_0000.jpg
/home/xxx/documents/gits/alexab/darknet/build/darknet/x64/data/obj/test_0001.jpg
/home/xxx/documents/gits/alexab/darknet/build/darknet/x64/data/obj/test_0002.jpg
/home/xxx/documents/gits/alexab/darknet/build/darknet/x64/data/obj/test_0003.jpg
/home/xxx/documents/gits/alexab/darknet/build/darknet/x64/data/obj/test_0004.jpg
/home/xxx/documents/gits/alexab/darknet/build/darknet/x64/data/obj/test_0005.jpg
/home/xxx/documents/gits/alexab/darknet/build/darknet/x64/data/obj/test_0006.jpg
/home/xxx/documents/gits/alexab/darknet/build/darknet/x64/data/obj/test_0007.jpg
/home/xxx/documents/gits/alexab/darknet/build/darknet/x64/data/obj/test_0008.jpg

Is there any problem? Thank you very very much!

lazerliu commented 4 years ago

While I use the original darknet yolov3 valid these same images,it generate the right json like this


{"image_id":0, "category_id":2, "bbox":[356.486206, 2.146976, 12.569397, 7.220934], "score":0.029387},
{"image_id":0, "category_id":2, "bbox":[311.298920, 2.309143, 28.693665, 17.816805], "score":0.006101},
{"image_id":1, "category_id":2, "bbox":[378.651367, 288.187378, 12.964233, 16.216003], "score":0.991247},
{"image_id":1, "category_id":1, "bbox":[289.078491, 54.320377, 21.093567, 8.391327], "score":0.006931},
{"image_id":1, "category_id":2, "bbox":[289.078491, 54.320377, 21.093567, 8.391327], "score":0.640269},
{"image_id":1, "category_id":1, "bbox":[255.469391, 489.705231, 30.240356, 10.294769], "score":0.079129},
{"image_id":1, "category_id":1, "bbox":[267.355560, 493.283203, 18.491638, 6.514526], "score":0.035697},
AlexeyAB commented 4 years ago

You can use ./darknet detector valid only for MSCOCO, PascalVOC, BDD100k, Kitti and ImageNet datasets.

For you custom dataset you should use ./darknet detector map...

You can't get AP_s, AP_l, ... for you custom dataset. You should implement your own code.

lazerliu commented 4 years ago

Thanks for your reply,I will try to implement it.

latifisalar commented 3 years ago

@lazerliu Did you manage to find the issue? I am facing the same problem while generating the coco_results.json with ./darknet detector valid for 5k.txt set of images on val2014.

shaojiestar commented 3 years ago

Thanks for your reply,I will try to implement it.

I am facing the same problem,have you solved this issue? or could you implement this?

Fushier commented 2 years ago

@lazerliu Did you manage to find the issue? I am facing the same problem while generating the coco_results.json with ./darknet detector valid for 5k.txt set of images on val2014.

Because the name format of "val2014" is "COCO_val2014_000000522418.jpg",but in : https://github.com/AlexeyAB/darknet/blob/9ff8653d999c8a22bc8f1ff4f4a8a3cc5b63d255/src/detector.c#L463, It uses base_cfg(): https://github.com/AlexeyAB/darknet/blob/9ff8653d999c8a22bc8f1ff4f4a8a3cc5b63d255/src/utils.c#L168 So the file name of val2014 can't be parsed to int in line465, then you can see all the image_ids are zeros. You can uncomment the get_coco_image_id(image_path) then it will work. If you are using a custom dataset, you can also change the code of get_coco_image_id to get the correct image_id.