AlexeyAB / darknet

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

test on a list of images #244

Open anandkoirala opened 7 years ago

anandkoirala commented 7 years ago

Hi @AlexeyAB Trained and tested well on custom data set... I tried to test on a list of images at a time using a .txt file as a parameter instead of image name. But the error is 'unknown image type' .... as the code is expecting image not a text file.

I have gone through other conversation issue #125 and followed the steps. . I have changed yolo_console_dll.cpp file to accept my .cfg and .weights files. the model loads and outputs the list of images in terminal and outputs the res... files but without detection..

The yolo_console_dll solution is using yolo.c file which has the list of default voc names ( i have a custom object only one class) and points to different directories for train_images and backup. But I was not required to change this thing for training and testing on custom data and everything went good.

Can you please suggest me of changes to the test command to accept a .txt file with list of images rather than just the image file.. OR do i have to change the yolo.c code (change voc names and target directories) if i have to use the .dll file? OR is there way to just give path to the folder containing images? Kind regards, Anand

zhang11wu4 commented 7 years ago

@anandkoirala Could you tell me whats cmd you use to train and test images,thanks! Because I always get zero objects even if I get loss only 0.04.

anandkoirala commented 7 years ago

@zhang11wu4 darknet.exe if you build the solution with gpu else darknet_no_gpu.exe darknet.exe detector train ./cfg/obj.data ./cfg/tiny-yolo-voc.cfg darknet19_448.conv.23 darknet.exe detector test ./cfg/obj.data ./cfg/tiny-yolo-voc.cfg ./backup/tiny-yolo-voc_2800.weights ./test.png dsfd tinyyolosummary while using the test command append -thresh 0 to see if there are any boxes... darknet.exe detector test ./cfg/obj.data ./cfg/tiny-yolo-voc.cfg ./backup/tiny-yolo-voc_2800.weights -thresh 0 Note on windows i use ./ to crawl to the target directory/file path from where i am running the command prompt ( i do a cd to where darknet.exe is and then from there the path is relative) i have obj.data instead of voc.data and i have kept it inside cfg folder rather than data folder. my weights are saved inside backup folder. the pre-trained initial weight file darknet19_448.conv.23 and my test file are on the same folder where darknet.exe is.. Hope this will help you.. Anand

zhang11wu4 commented 7 years ago

@anandkoirala thanks! Could you tell me which commit you are using?

AlexeyAB commented 7 years ago

The yolo_console_dll solution is using yolo.c file which has the list of default voc names ( i have a custom object only one class) and points to different directories for train_images and backup.

@anandkoirala No, yolo_console_dll doesn't use yolo.c. Files with object names specified in this line: https://github.com/AlexeyAB/darknet/blob/6ccb41808caf753feea58ca9df79d6367dedc434/src/yolo_console_dll.cpp#L90


I have gone through other conversation issue #125 and followed the steps. . I have changed yolo_console_dll.cpp file to accept my .cfg and .weights files. the model loads and outputs the list of images in terminal and outputs the res... files but without detection..

Try to uncomment this line: https://github.com/AlexeyAB/darknet/blob/6ccb41808caf753feea58ca9df79d6367dedc434/src/yolo_console_dll.cpp#L173

anandkoirala commented 7 years ago

@AlexeyAB thanks for the information... i have uncommented those lines.. i can see too many boxes drawn on image and co-ordinates on the terminal but only when threshold is below 0.03 However the same weights and model works with default threshold when doing a normal test (without using .dll)

in my project i have added few lines of code to output the image name and counts to a .csv file for record ( as i have to get count for more than a thousand images at a time). I don't want to manually run a test for each image therefore i coded a batch script which iterates over all images in a folder and runs test from the command and i get a record of name and counts.. in doing so the model has to be re-loaded for each image. I was looking if the current repo can take list of images for testing (inference) so the model is loaded only once?.. Regards, Anand

anandkoirala commented 7 years ago

@zhang11wu4 i am using the windows branch.. and the use of ../ or ./ was always beneficial even if the code is originally written for Linux.

zhang11wu4 commented 7 years ago

@anandkoirala thanks! I tried commit 6ccb418, it works, I can detect objects successfully with 4000 iterations with original dataset including stop signs and yield signs. Train cmd: darknet.exe detector train data/obj.data yolo-obj.cfg darknet19_448.conv.23 Test cmd: darknet.exe detector test data/obj.data yolo-obj.cfg backup/yolo-obj_4000.weights

AlexeyAB commented 7 years ago

@anandkoirala

@AlexeyAB thanks for the information... i have uncommented those lines.. i can see too many boxes drawn on image and co-ordinates on the terminal but only when threshold is below 0.03 However the same weights and model works with default threshold when doing a normal test (without using .dll)

This is very strange. Can you see any bounded boxes using default yolo-voc.weights/cfg files with default threshold 0.2 using yolo_console_dll.exe?


I was looking if the current repo can take list of images for testing (inference) so the model is loaded only once?..

Yes, you can: darknet.exe detector test data/voc.data yolo-voc.cfg yolo-voc.weights < list_image_names.txt

Also you can comment this line so that each image does not require pressing the button ESC: https://github.com/AlexeyAB/darknet/blob/6ccb41808caf753feea58ca9df79d6367dedc434/src/detector.c#L509

anandkoirala commented 7 years ago

@AlexeyAB Sorry for the late reply but i used imagelist file as input refered above comments from you but the model crashes after two images from the list. I have checked and the list is all good and the image exist.

jasleen137 commented 5 years ago

Hi @AlexeyAB I have followed the steps given in #125 and this post but when I open yolo_console_dll.exe with an image , it just shows used GPU 0 and exits, it doesn't show the bounding boxes on the image nor does it give any res files.