darknet icon indicating copy to clipboard operation
darknet copied to clipboard

how to calculate mAP?

Open yushanshan05 opened this issue 6 years ago • 24 comments

I found that the ./darknet detector recall function, but it only calculate the recall without fp,tp and mAP. how to calculate mAP? Thanks!

yushanshan05 avatar Apr 10 '18 02:04 yushanshan05

./darknet detector map .data .cfg .weights

ahsan856jalal avatar Apr 10 '18 06:04 ahsan856jalal

@ahsan856jalal ./darknet detector map .data .cfg .weights There is not map in darknet\examples\detector.c. There is only train,valid,recall and demo. I don't understand how to use map. Please help me! Thanks a lot!

if(0==strcmp(argv[2], "test")) test_detector(datacfg, cfg, weights, filename, thresh, hier_thresh, outfile, fullscreen); else if(0==strcmp(argv[2], "train")) train_detector(datacfg, cfg, weights, gpus, ngpus, clear); else if(0==strcmp(argv[2], "valid")) validate_detector(datacfg, cfg, weights, outfile); else if(0==strcmp(argv[2], "valid2")) validate_detector_flip(datacfg, cfg, weights, outfile); else if(0==strcmp(argv[2], "recall")) validate_detector_recall(cfg, weights); else if(0==strcmp(argv[2], "demo")) { list *options = read_data_cfg(datacfg); int classes = option_find_int(options, "classes", 20); char *name_list = option_find_str(options, "names", "data/names.list"); char **names = get_labels(name_list); demo(cfg, weights, thresh, cam_index, filename, names, classes, frame_skip, prefix, avg, hier_thresh, width, height, fps, fullscreen); }

yushanshan05 avatar Apr 10 '18 09:04 yushanshan05

@yushanshan05 it is because @ahsan856jalal answer is for another fork, he should have clarified that. If you want to use that command you should check out AlexeyAB's fork

Here is a permalink to the command

TheMikeyR avatar Apr 10 '18 09:04 TheMikeyR

@ahsan856jalal is, like often, refering to @AlexeyAB 's fork : AlexeyAB/darknet

baristahell avatar Apr 10 '18 09:04 baristahell

@ahsan856jalal I tried detector map but it didnt show any results in the console. Also it didnt give any errors. usually where does it show or store the map values ? Thanks in advance !

Thilanka97 avatar Mar 12 '19 09:03 Thilanka97

./darknet detector map .data .cfg .weights

I use that command but it didn't work for me and didn't show any report, file or ...

barzan-hayati avatar Dec 18 '19 09:12 barzan-hayati

./darknet detector map .data .cfg .weights I use that command but it didn't work for me and didn't show any report, file or ...

musimab avatar Apr 28 '20 20:04 musimab

@ahsan856jalal I tried detector map but it didnt show any results in the console. Also it didnt give any errors. usually where does it show or store the map values ? Thanks in advance !

Did you solve this issue?

bahulkark avatar Jun 13 '20 04:06 bahulkark

I also have the same issue. I wrote this command in darknet directory: ./darknet detector map custom/project.data custom/yolov3-project.cfg custom/yolov3-project_final.weights but I did not give any result or error. Also, I trained the data again by adding "-map" command to train code in terminal but there is same problem.

bsrc avatar Jun 14 '20 11:06 bsrc

You should run: !./darknet detector map data/obj.data path_to_weights.weights -dont_show -ext_output < path_to_the_txt_that_has_all_the_images_you_want_to_detect.txt > result.txt In this case, I'm running the detecting for multiple images, so I have a .txt file that lists all the images path, just like the one you used for training.

Then for downloading the file just: download('result.txt') In case you are training in collab or simmilar

laizaparizotto avatar Jul 15 '20 13:07 laizaparizotto

tried running !./darknet detector valid "/content/darknet/data/obj.data.txt" "/content/darknet/cfg/yolov3-custom.cfg" "/content/gdrive/My Drive/yolov3_weights/backup2/yolov3-custom_final.weights" but that just gave me a segmentation fault, the paths are all correct tho :(

edit1: the segmentation fault here was because of the combination of quotes and the added '/' in the beginning of the file path. runs without it!

kshitijnair avatar Aug 17 '20 18:08 kshitijnair

@laizaparizotto I ran ./darknet detector map data/debris.data backup/yolov4-debris_final.weights -dont_show -ext_output < data/test.txt > result.txt But I am getting a segmentation error: CUDA-version: 10020 (10020), GPU count: 1 OpenCV version: 3.2.0 valid: Using default 'data/train.txt' Segmentation fault (core dumped) Any idea what my problem might be?

milton-logothetis avatar Aug 19 '20 18:08 milton-logothetis

In response to my previous post you also need to specify .cfg file (...duh). Hence, ./darknet detector map data/obj.data cfg/yolov4-custom.cfg backup/yolov4-custom_final.weights -dont_show -ext_output < data/test.txt > result.txt Will calculate mAP.

milton-logothetis avatar Aug 19 '20 18:08 milton-logothetis

I tried doing this line in google colab: !./darknet detector map data/obj.data cfg/yolov3_training.cfg /content/gdrive/MyDrive/yolov3/yolov3_training_last_5_6_21.weights -dont_show -ext_output <data/test.txt> result.txt This error still shows up: /bin/bash: data/test.txt: No such file or directory

geni09 avatar May 09 '21 00:05 geni09

It now works. I just used this line to copy the contents of train.txt (which contains jpg paths) to test.txt (which was non-existent in the first place) !cp data/train.txt data/test.txt Then printed the result using this line: !cat data/result.txt

geni09 avatar May 09 '21 01:05 geni09

Hello guys. I am working with image classification but I am noob. I tried to calculate the mAp by trying the following code. However, it does not give any output. What am I doing wrong?

./darknet detector map cfg/coco.data cfg/yolov3.cfg yolov3.weights

baspinarenes avatar May 16 '21 12:05 baspinarenes

May I know , in order to calculate mAP what changes we have to make in .data file, when we already have the ground truths corresponding to every images . ? The ground truth file is. : https://drive.google.com/file/d/1mfWXwk8AhZ4xxonMboPx-Anxe-fdugiP/view?usp=sharing And the predicted file is : https://drive.google.com/file/d/1MNX1522F-Q_d4HetIRbAW8dyfyBEszJw/view?usp=sharing

Riankk123 avatar May 18 '21 07:05 Riankk123

So, how to calculate mAP on COCO with this repo ?

zhonhel avatar Aug 31 '21 04:08 zhonhel

how do we get mAP50, mAP75 ?

maheshchahare avatar Jan 11 '22 06:01 maheshchahare

@maheshchahare you can specify the threshold by adding "-thresh 0.5" to the detector code line.

For instance:

./darknet detector map file_file.data file_file.cfg file_file.weights -ext_output < file_file.txt > file_file.txt -thresh 0.5

laizaparizotto avatar Jan 11 '22 06:01 laizaparizotto

Hello guys,

I am new to Yolov3 and I tried so many times execute the command you suggested on Google Colab, however everytime I execute the result is according to image bellow:

Resultado_validação

When I take some image of the dataset I am using to test the result is good, as the image bellow:

Resultado_validação

Some suggestion, please?

BrunoRomao98 avatar Mar 18 '22 00:03 BrunoRomao98

@BrunoRomao98 Did you solve the issue.

Harikrishnanvjtrois avatar Dec 28 '22 06:12 Harikrishnanvjtrois

No dude

On Wed, Dec 28, 2022, 12:29 Harikrishnanvjtrois @.***> wrote:

@BrunoRomao98 https://github.com/BrunoRomao98 Did you solve the issue.

— Reply to this email directly, view it on GitHub https://github.com/pjreddie/darknet/issues/671#issuecomment-1366415972, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYFPJGYQSCN3ZSITVIGGYETWPPQNPANCNFSM4EZWAO7Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

harshareddie avatar Dec 28 '22 11:12 harshareddie