Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I test many pictures one time, and save all predictions and results? #1396

Closed
RosaShao opened this issue Aug 14, 2018 · 7 comments
Closed

Comments

@RosaShao
Copy link

Thanks for your help few days ago.
I have another question, how can I test many pictures one time, and save all predict pictures and results?
""""darknet.exe detector test data/coco.data cfg/yolov3.cfg yolov3.weights -i 0 -thresh 0.25"""
I know use that can get results, but I want get all predict pictures.
How can I do, could you help me?
Thank you!

@SiNcSaD
Copy link

SiNcSaD commented Aug 15, 2018

#519 Refer to this issue.

@RosaShao
Copy link
Author

@SiNcSaD Thanks for your kind help.
But I'm a python beginner, no experience in writing c programs, it's hard to understand your discuss.
Indeed, I'm not really know how to modify the """Python Code: detect_multi_images.py """ according to AlexeyAB's solution. (I detect on linux, too.)
I also can't understand to modify the code of the function 'test_detector()'.
Could you give some help?
Thank you so much!

@SiNcSaD
Copy link

SiNcSaD commented Aug 16, 2018

@RosaShao, Hi

I started with a bad solution: detect_multi_images.py
Don't try it because the execution time is too long.

First you have to do this, then sure to successfully generate result.txt.
This result.txt just records the contents of predict process.
The content of results.txt:

seen 32 
Enter Image Path: pic/000001.jpg: Predicted in 0.012083 seconds.
ship: 90%
Enter Image Path: pic/000002.jpg: Predicted in 0.011978 seconds.
ship: 89%
Enter Image Path: pic/000003.jpg: Predicted in 0.010273 seconds.
ship: 90%
Enter Image Path: pic/000004.jpg: Predicted in 0.010057 seconds.
ship: 87%
Enter Image Path: pic/000005.jpg: Predicted in 0.010159 seconds.
ship: 89%
Enter Image Path: pic/000006.jpg: Predicted in 0.010014 seconds.
ship: 92%
ship: 87%
ship: 80%
Enter Image Path: pic/000007.jpg: Predicted in 0.010259 seconds.
ship: 85%
Enter Image Path: pic/000008.jpg: Predicted in 0.010238 seconds.
ship: 87%
Enter Image Path: pic/000009.jpg: Predicted in 0.010003 seconds.
ship: 88%
Enter Image Path: pic/000010.jpg: Predicted in 0.010041 seconds.
ship: 88%
.
.
.

When you are done, I will continue to explain how to save multiple images using test_detector().

@RosaShao
Copy link
Author

Yes, I'm done!
seen 32
Enter Image Path: /home/rosashao/darknet-master2/pic/000001.jpg: Predicted in 0.018490 seconds.
0: 100%
0: 100%
0: 100%
5: 100%
Enter Image Path: /home/rosashao/darknet-master2/pic/000002.jpg: Predicted in 0.018463 seconds.
0: 100%
0: 34%
p: 100%
0: 100%
p: 99%
0: 100%
0: 100%
0: 100%
2: 100%
0: 100%
.
.
.
.
Please continue!

@SiNcSaD
Copy link

SiNcSaD commented Aug 16, 2018

@RosaShao

Change ls -d "$PWD"/pic/* > filelist.txt to ls -d pic/* > filelist.txt

We don't want absolute paths: /home/rosashao/darknet-master2/pic/000001.jpg
We want a relative path: pic/000001.jpg

  • Add #include "memory.h" to the line below.
    #include "option_list.h"
  • Add the following code between L1144 and L1145
    • This is a simple string formatting code, I think you can try Google research to understand.
char output[6];
memcpy(output, input + 4, 6);
char buff[256];
sprintf(buff, "results/%s", output);
save_image(im, buff);

darknet/src/detector.c

Lines 1144 to 1147 in c2a8cc2

save_image(im, "predictions");
if (!dont_show) {
show_image(im, "predictions");
}

  • Do make in the darknet directory
  • Do ./darknet detector test ...

If successful, you will see the predicted images in the results folder.

@RosaShao
Copy link
Author

I really don't know how to express my thanks.
It's work!
It's work!
This problem has plagued me for a three weeks.
Thank you so much!

@SiNcSaD
Copy link

SiNcSaD commented Aug 17, 2018

@RosaShao
Good job!
If no problem, remember to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants