pjreddie / darknet

Convolutional Neural Networks
http://pjreddie.com/darknet/
Other
25.69k stars 21.33k forks source link

Run YoloV3 detections on thousands of images and save outputs? #723

Closed austinmw closed 6 years ago

austinmw commented 6 years ago

I've only figured out how to run detections on one image at a time, typing a new image filename each time. Is there any build-in way to run on an entire folder of images and save images with predictions to another folder?

AlexeyAB commented 6 years ago

Using this fork: https://github.com/AlexeyAB/darknet you can use this command: ./darknet detector test data/voc.data yolo-voc.cfg yolo-voc.weights -dont_show < data/train.txt > result.txt

in the file data/train.txt you should have paths to images in the file result.txt will be results of detections

austinmw commented 6 years ago

Thanks for the reply. does that work with YoloV3 config files? edit: looks like it should, gonna try now!

AlexeyAB commented 6 years ago

@austinmw Yes. For Yolo v3: ./darknet detector test ./cfg/coco.data ./cfg/yolov3.cfg ./yolov3.weights -dont_show < data/train.txt > result.txt

austinmw commented 6 years ago

Thanks. Does this actually save images with bounding boxes overlaid or only save bounding box info into a txt file? Trying to piece the separate detection images into a video as my build is freezing when trying to pass videos

AlexeyAB commented 6 years ago

It only saves bounding box info into a txt file

austinmw commented 6 years ago

Ah ok, happen to know any way to save prediction images like ./darknet detect only with multiple images?

surajitkundu29 commented 6 years ago

@austinmw did you get the way to save the images instead of only text file

worldmovers commented 6 years ago

@AlexeyAB I am using darknet fork from the yolo website. I have already trained my model on yolov3 . Now I want to make prediction on a folder . I tried using this ./darknet detector test data/voc.data yolo-voc.cfg yolo-voc.weights -dont_show < data/train.txt > result.txt but that's not working. Can you please help me

austinmw commented 6 years ago

@surajitkundu29 I didn't find an option directly. One workaround is that it will save bounding boxes over video output. So what you could do is combine your images (if they are the same size) into a video, run detection on the video, then split them back up.

AlexeyAB commented 6 years ago

@worldmovers Try to use this fork for detection: https://github.com/AlexeyAB/darknet

mhusseinsh commented 6 years ago

@AlexeyAB Is there a way to save output images with bounding boxes in a different folder ? I have a directory with thousands of input images, and I created an input.txt path for the images, and I am passing them in the command, but the output is always overriden for each frame on predictions.png I need to save multiple outputs what can I do ?

PeterQuinn925 commented 6 years ago

Mostafa, Write yourself a little bit of python to call Darknet and you do do whatever you want with the pictures. Example here: https://github.com/PeterQuinn925/Squirrel/commit/d514aa280c9d203519ea2c2877147e85af3a0312

On Mon, Jul 30, 2018 at 1:49 AM Mostafa Hussein notifications@github.com wrote:

@AlexeyAB https://github.com/AlexeyAB Is there a way to save output images with bounding boxes in a different folder ? I have a directory with thousands of input images, and I created an input.txt path for the images, and I am passing them in the command, but the output is always overriden for each frame on predictions.png I need to save multiple outputs what can I do ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pjreddie/darknet/issues/723#issuecomment-408792715, or mute the thread https://github.com/notifications/unsubscribe-auth/ARocJbKTi38A63u87I0E3SvSYVWJcisKks5uLsivgaJpZM4Ten8t .

-- Peter Quinn (415) 794-2264 (cell)

mhusseinsh commented 6 years ago

@PeterQuinn925 I already did a little bash, which performs the images one by one, but the problem which i am facing now, is that each time, the image is saved as predictions.png, so it is always overwritten

and I am trying to find a way to avoid that

here is how I do it cat imagenames.txt | ./darknet detect cfg/yolov3.cfg yolov3.weights

berinhard commented 6 years ago

@mhusseinsh I've forked darknet and implemented an ad-hoc solution that worked for me. If you want to take a look, here's the commit.

Muhammad057 commented 6 years ago

@mhusseinsh Here's a python code to save multiple images from a test.txt file.

import os import glob os.system import PIL import PIL.Image as Image

d = 0 test_Path = r'E:\ANPR\darknet\build\darknet\x64\data\test' with open((test_Path + '.txt'),'r') as fobj: for line in fobj: image_List = [[num for num in line.split()] for line in fobj] for images in image_List: commands = ['darknet.exe detector test data/obj.data yolo-obj_test.cfg backup/yolo-obj_4900.weights -dont_show', images[0]] os.system(' '.join(commands)) predicted_image = Image.open("E:/ANPR/darknet/build/darknet/x64/predictions.jpg") output = "E:/ANPR/darknet/build/darknet/x64/data/predictedimages/predicted_image%d.jpg"%d predicted_image.save(output) d+=1

buzdarbalooch commented 5 years ago

hi,

i ran that script successfully, in the result.txt file it stores the predicted class of each image in the train.txt and % of the prediction. What if for each prediction. One wants the coordinates of the bounding boxes of the predicted class in the image.

buzdarbalooch commented 5 years ago

@AlexeyAB can you please help?

vikasmishra591 commented 5 years ago

Hi, I am getting prediction for single images but when I tried for multiple images it is creating result.txt file but empty and showing error like could not open names.list file.

rodrigoap commented 5 years ago

There is a -out option:

./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights data/dog.jpg -out myfile

Will write the image to myfile.jpg

srhtyldz commented 5 years ago

There is a -out option:

./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights data/dog.jpg -out myfile

Will write the image to myfile.jpg

can you do that for the folder that contains test images =?

srhtyldz commented 5 years ago

@AlexeyAB I am using darknet fork from the yolo website. I have already trained my model on yolov3 . Now I want to make prediction on a folder . I tried using this ./darknet detector test data/voc.data yolo-voc.cfg yolo-voc.weights -dont_show < data/train.txt > result.txt but that's not working. Can you please help me

That script also does not worked for me .How did you find a solution to save output of test data ?

vincentgong7 commented 5 years ago

Updated: May 07, 2020

I added the function of exporting the bounding box coordinates and classes names, confidence for each image in an input folder.

Now it supports:

Try now:

https://darknet.gong.im/

Updated: May 14, 2019

Batch images detection using Yolo on AexeyAB Darknet: https://darknet.gong.im/

I added this function in the source code and resolve this problem with command:

Command

./darknet detector batch cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch exp/in_images/ exp/out_images/ > result/results.txt

Parameter explain:

  1. The input images are: in_images/
  2. The output images are: out_images/
  3. The detection classes with percentage is saved in: exp/results/results.txt

As AlexeyAB updates frequently, hereby I added a stable version of AlexeyAB Darknet with extra convenient functions into my Github repos. https://github.com/vincentgong7/VG_AlexeyAB_darknet

Usage

  1. Clone this project. See the repo in above link.
  2. Download pre-trained weights file into foder ./weights/. Such as: https://pjreddie.com/media/files/yolov3-openimages.weights
  3. Make the project with command in VG_AlexeyAB_darknet/ folder:

    make

  4. Use the command described above to perform batch detecting images.

Contact

Any questions please let me know.
vincent.gong7[at]gmail.com
http://www.gong.im

Best Regards, Vincent

vincentgong7 commented 5 years ago

@AlexeyAB I am using darknet fork from the yolo website. I have already trained my model on yolov3 . Now I want to make prediction on a folder . I tried using this ./darknet detector test data/voc.data yolo-voc.cfg yolo-voc.weights -dont_show < data/train.txt > result.txt but that's not working. Can you please help me

That script also does not worked for me .How did you find a solution to save output of test data ?

Solved! Please see my answer above.

vincentgong7 commented 5 years ago

hi,

i ran that script successfully, in the result.txt file it stores the predicted class of each image in the train.txt and % of the prediction. What if for each prediction. One wants the coordinates of the bounding boxes of the predicted class in the image.

Solved! Please see my answer above.

vincentgong7 commented 5 years ago

@AlexeyAB Is there a way to save output images with bounding boxes in a different folder ? I have a directory with thousands of input images, and I created an input.txt path for the images, and I am passing them in the command, but the output is always overriden for each frame on predictions.png I need to save multiple outputs what can I do ?

Solved! Please see my answer above.

vincentgong7 commented 5 years ago

@surajitkundu29 I didn't find an option directly. One workaround is that it will save bounding boxes over video output. So what you could do is combine your images (if they are the same size) into a video, run detection on the video, then split them back up.

Solved! Please see my answer above.

Yddeon commented 5 years ago

I added this function in the source code and resolve this problem with command:

./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch ./in_images/ ./out_images/ >./results.txt

Parameter explain:

* The input images are: `./in_images/`

* The output images are: `./out_images/`

* The detection classes with percentage is saved in: `./results.txt`

To reach this, you need to replace the attached detector.c into ./src/ folder and re-make the AlexeyAB darknet.

Detail process:

1. Install the AlexeyAB/darknet, see: [github link](https://github.com/AlexeyAB/darknet). The darknet is installed in the folder: `darknet/`

2. Replace the `darknet/src/detector.c` with the detector.c in attached.
   [detector.c.zip](https://github.com/pjreddie/darknet/files/2674089/detector.c.zip)

3. Make the project with command in `darknet/` folder:
   `make`

4. If you have already did the make, you may do re-make with commands:
   `clean`
   `make`

You may still do for one image with: ./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights ./data/dog.jpg

Any questions please let me know. vincent.gong7[at]gmail.com

Best Regards, Vincent

I managed to make your solution work but I'm still having some issues with the output! I have a bunch of .jpg images ordered in in_images folder (1.jpg, 2.jpg ... 30.jpg) and it's succesfully saving them all but as 1.jpg.png, 2.jpg.png..

Is there a way to remove the .jpg from input files? Or keep them as jpg when saving

I'm currently solving this by running find -type f -name '*.png' | while read f; do mv "$f" "${f%.png}"; done after the program is done but it would be nice if the oput was already the one I'm expecting without running anything afterwards

vincentgong7 commented 5 years ago

I added this function in the source code and resolve this problem with command:

./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch ./in_images/ ./out_images/ >./results.txt

Parameter explain:

* The input images are: `./in_images/`

* The output images are: `./out_images/`

* The detection classes with percentage is saved in: `./results.txt`

To reach this, you need to replace the attached detector.c into ./src/ folder and re-make the AlexeyAB darknet.

Detail process:

1. Install the AlexeyAB/darknet, see: [github link](https://github.com/AlexeyAB/darknet). The darknet is installed in the folder: `darknet/`

2. Replace the `darknet/src/detector.c` with the detector.c in attached.
   [detector.c.zip](https://github.com/pjreddie/darknet/files/2674089/detector.c.zip)

3. Make the project with command in `darknet/` folder:
   `make`

4. If you have already did the make, you may do re-make with commands:
   `clean`
   `make`

You may still do for one image with: ./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights ./data/dog.jpg Any questions please let me know. vincent.gong7[at]gmail.com Best Regards, Vincent

I managed to make your solution work but I'm still having some issues with the output! I have a bunch of .jpg images ordered in in_images folder (1.jpg, 2.jpg ... 30.jpg) and it's succesfully saving them all but as 1.jpg.png, 2.jpg.png..

Is there a way to remove the .jpg from input files? Or keep them as jpg when saving

I'm currently solving this by running find -type f -name '*.png' | while read f; do mv "$f" "${f%.png}"; done after the program is done but it would be nice if the oput was already the one I'm expecting without running anything afterwards

Thanks Yddeon, I'll modify on it before next week. BR, Vincent

srhtyldz commented 5 years ago

I added this function in the source code and resolve this problem with command:

./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch ./in_images/ ./out_images/ >./results.txt

Parameter explain:

  • The input images are: ./in_images/
  • The output images are: ./out_images/
  • The detection classes with percentage is saved in: ./results.txt

To reach this, you need to replace the attached detector.c into ./src/ folder and re-make the AlexeyAB darknet.

Detail process:

  1. Install the AlexeyAB/darknet, see: github link. The darknet is installed in the folder: darknet/
  2. Replace the darknet/src/detector.c with the detector.c in attached. detector.c.zip
  3. Make the project with command in darknet/ folder: make
  4. If you have already did the make, you may do re-make with commands: clean make

You may still do for one image with: ./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights ./data/dog.jpg

Any questions please let me know. vincent.gong7[at]gmail.com

Best Regards, Vincent

I think this is worked for me but still not sure "Not compiled with OpenCV, saving to ./data/output/person_and_bike_092.png.png instead Not compiled with OpenCV, saving to ./data/output/person_and_bike_014.png.png instead Not compiled with OpenCV, saving to ./data/output/crop001688.png.png instead "

when the script is run, the output is like that. Does it say that opencv is not installed that's why compiled ? could you please light me up for that ?

vincentgong7 commented 5 years ago

Hi all, I have resolved the problem about the file name. I’ll update the code in about 4 hours. Good weekend!

BR, Vincent

srhtyldz commented 5 years ago

Hi all, I have resolved the problem about the file name. I’ll update the code in about 4 hours. Good weekend!

BR, Vincent

I have a question for that.You get result.txt file at the end.Can you calculate mAP (mean average precision) with result.txt file ? if not, how can you calculate ?

vincentgong7 commented 5 years ago

Hi all,

The detector.c file is updated fixing the file name problem. please check it out: https://github.com/vincentgong7/AlexeyAB_darknet/blob/master/detector.c I'll also update my previous post for the multiple images process problem here: https://github.com/pjreddie/darknet/issues/723#issuecomment-446801283

BR, Vincent

vincentgong7 commented 5 years ago

I added this function in the source code and resolve this problem with command:

./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch ./in_images/ ./out_images/ >./results.txt

Parameter explain:

  • The input images are: ./in_images/
  • The output images are: ./out_images/
  • The detection classes with percentage is saved in: ./results.txt

To reach this, you need to replace the attached detector.c into ./src/ folder and re-make the AlexeyAB darknet.

Detail process:

  1. Install the AlexeyAB/darknet, see: github link. The darknet is installed in the folder: darknet/
  2. Replace the darknet/src/detector.c with the detector.c in attached. detector.c.zip
  3. Make the project with command in darknet/ folder: make
  4. If you have already did the make, you may do re-make with commands: clean make

You may still do for one image with: ./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights ./data/dog.jpg Any questions please let me know. vincent.gong7[at]gmail.com Best Regards, Vincent

I think this is worked for me but still not sure "Not compiled with OpenCV, saving to ./data/output/person_and_bike_092.png.png instead Not compiled with OpenCV, saving to ./data/output/person_and_bike_014.png.png instead Not compiled with OpenCV, saving to ./data/output/crop001688.png.png instead "

when the script is run, the output is like that. Does it say that opencv is not installed that's why compiled ? could you please light me up for that ?

The same printed in my side. I think it means the OpenCV is turned off (either because it is not installed or because it is not turned on). The result should be not affected.

srhtyldz commented 5 years ago

I added this function in the source code and resolve this problem with command:

./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch ./in_images/ ./out_images/ >./results.txt

Parameter explain:

  • The input images are: ./in_images/
  • The output images are: ./out_images/
  • The detection classes with percentage is saved in: ./results.txt

To reach this, you need to replace the attached detector.c into ./src/ folder and re-make the AlexeyAB darknet.

Detail process:

  1. Install the AlexeyAB/darknet, see: github link. The darknet is installed in the folder: darknet/
  2. Replace the darknet/src/detector.c with the detector.c in attached. detector.c.zip
  3. Make the project with command in darknet/ folder: make
  4. If you have already did the make, you may do re-make with commands: clean make

You may still do for one image with: ./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights ./data/dog.jpg Any questions please let me know. vincent.gong7[at]gmail.com Best Regards, Vincent

I think this is worked for me but still not sure "Not compiled with OpenCV, saving to ./data/output/person_and_bike_092.png.png instead Not compiled with OpenCV, saving to ./data/output/person_and_bike_014.png.png instead Not compiled with OpenCV, saving to ./data/output/crop001688.png.png instead " when the script is run, the output is like that. Does it say that opencv is not installed that's why compiled ? could you please light me up for that ?

The same printed in my side. I think it means the OpenCV is turned off (either because it is not installed or because it is not turned on). The result should be not affected.

I have one more question.Can we get coordinates of detected images to calculate the mAP ? I think that the result text file only contains the percentage of guess.How can we get that ? Do you have a suggestion or help ?

vincentgong7 commented 5 years ago

I added this function in the source code and resolve this problem with command:

./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch ./in_images/ ./out_images/ >./results.txt

Parameter explain:

* The input images are: `./in_images/`

* The output images are: `./out_images/`

* The detection classes with percentage is saved in: `./results.txt`

To reach this, you need to replace the attached detector.c into ./src/ folder and re-make the AlexeyAB darknet.

Detail process:

1. Install the AlexeyAB/darknet, see: [github link](https://github.com/AlexeyAB/darknet). The darknet is installed in the folder: `darknet/`

2. Replace the `darknet/src/detector.c` with the detector.c in attached.
   [detector.c.zip](https://github.com/pjreddie/darknet/files/2674089/detector.c.zip)

3. Make the project with command in `darknet/` folder:
   `make`

4. If you have already did the make, you may do re-make with commands:
   `clean`
   `make`

You may still do for one image with: ./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights ./data/dog.jpg Any questions please let me know. vincent.gong7[at]gmail.com Best Regards, Vincent

I managed to make your solution work but I'm still having some issues with the output! I have a bunch of .jpg images ordered in in_images folder (1.jpg, 2.jpg ... 30.jpg) and it's succesfully saving them all but as 1.jpg.png, 2.jpg.png..

Is there a way to remove the .jpg from input files? Or keep them as jpg when saving

I'm currently solving this by running find -type f -name '*.png' | while read f; do mv "$f" "${f%.png}"; done after the program is done but it would be nice if the oput was already the one I'm expecting without running anything afterwards

Solved, please see my above answer. The code is updated.

vincentgong7 commented 5 years ago

I added this function in the source code and resolve this problem with command:

./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch ./in_images/ ./out_images/ >./results.txt

Parameter explain:

  • The input images are: ./in_images/
  • The output images are: ./out_images/
  • The detection classes with percentage is saved in: ./results.txt

To reach this, you need to replace the attached detector.c into ./src/ folder and re-make the AlexeyAB darknet.

Detail process:

  1. Install the AlexeyAB/darknet, see: github link. The darknet is installed in the folder: darknet/
  2. Replace the darknet/src/detector.c with the detector.c in attached. detector.c.zip
  3. Make the project with command in darknet/ folder: make
  4. If you have already did the make, you may do re-make with commands: clean make

You may still do for one image with: ./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights ./data/dog.jpg Any questions please let me know. vincent.gong7[at]gmail.com Best Regards, Vincent

I think this is worked for me but still not sure "Not compiled with OpenCV, saving to ./data/output/person_and_bike_092.png.png instead Not compiled with OpenCV, saving to ./data/output/person_and_bike_014.png.png instead Not compiled with OpenCV, saving to ./data/output/crop001688.png.png instead " when the script is run, the output is like that. Does it say that opencv is not installed that's why compiled ? could you please light me up for that ?

The same printed in my side. I think it means the OpenCV is turned off (either because it is not installed or because it is not turned on). The result should be not affected.

I have one more question.Can we get coordinates of detected images to calculate the mAP ? I think that the result text file only contains the percentage of guess.How can we get that ? Do you have a suggestion or help ?

May I know the definition of mAP you referred here. Is it the average percentage of all those guess (%)? What is the coordinates? is it the bounding box of the object detected on the image? something like: car: 93% (left_x: 1 top_y: 802 width: 134 height: 47)

srhtyldz commented 5 years ago

I added this function in the source code and resolve this problem with command:

./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch ./in_images/ ./out_images/ >./results.txt

Parameter explain:

  • The input images are: ./in_images/
  • The output images are: ./out_images/
  • The detection classes with percentage is saved in: ./results.txt

To reach this, you need to replace the attached detector.c into ./src/ folder and re-make the AlexeyAB darknet.

Detail process:

  1. Install the AlexeyAB/darknet, see: github link. The darknet is installed in the folder: darknet/
  2. Replace the darknet/src/detector.c with the detector.c in attached. detector.c.zip
  3. Make the project with command in darknet/ folder: make
  4. If you have already did the make, you may do re-make with commands: clean make

You may still do for one image with: ./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights ./data/dog.jpg Any questions please let me know. vincent.gong7[at]gmail.com Best Regards, Vincent

I think this is worked for me but still not sure "Not compiled with OpenCV, saving to ./data/output/person_and_bike_092.png.png instead Not compiled with OpenCV, saving to ./data/output/person_and_bike_014.png.png instead Not compiled with OpenCV, saving to ./data/output/crop001688.png.png instead " when the script is run, the output is like that. Does it say that opencv is not installed that's why compiled ? could you please light me up for that ?

The same printed in my side. I think it means the OpenCV is turned off (either because it is not installed or because it is not turned on). The result should be not affected.

I have one more question.Can we get coordinates of detected images to calculate the mAP ? I think that the result text file only contains the percentage of guess.How can we get that ? Do you have a suggestion or help ?

May I know the definition of mAP you referred here. Is it the average percentage of all those guess (%)? What is the coordinates? is it the bounding box of the object detected on the image? something like: car: 93% (left_x: 1 top_y: 802 width: 134 height: 47)

If I'm wrong, please correct me . To calculate mAP,you need predicted values and ground truth. In our case,the values are something like that which is coordinates of bounding box; 00082 0.999969 504.637390 651.370789 610.118347 736.534363.

vincentgong7 commented 5 years ago

I added this function in the source code and resolve this problem with command:

./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch ./in_images/ ./out_images/ >./results.txt

Parameter explain:

  • The input images are: ./in_images/
  • The output images are: ./out_images/
  • The detection classes with percentage is saved in: ./results.txt

To reach this, you need to replace the attached detector.c into ./src/ folder and re-make the AlexeyAB darknet.

Detail process:

  1. Install the AlexeyAB/darknet, see: github link. The darknet is installed in the folder: darknet/
  2. Replace the darknet/src/detector.c with the detector.c in attached. detector.c.zip
  3. Make the project with command in darknet/ folder: make
  4. If you have already did the make, you may do re-make with commands: clean make

You may still do for one image with: ./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights ./data/dog.jpg Any questions please let me know. vincent.gong7[at]gmail.com Best Regards, Vincent

I think this is worked for me but still not sure "Not compiled with OpenCV, saving to ./data/output/person_and_bike_092.png.png instead Not compiled with OpenCV, saving to ./data/output/person_and_bike_014.png.png instead Not compiled with OpenCV, saving to ./data/output/crop001688.png.png instead " when the script is run, the output is like that. Does it say that opencv is not installed that's why compiled ? could you please light me up for that ?

The same printed in my side. I think it means the OpenCV is turned off (either because it is not installed or because it is not turned on). The result should be not affected.

I have one more question.Can we get coordinates of detected images to calculate the mAP ? I think that the result text file only contains the percentage of guess.How can we get that ? Do you have a suggestion or help ?

May I know the definition of mAP you referred here. Is it the average percentage of all those guess (%)? What is the coordinates? is it the bounding box of the object detected on the image? something like: car: 93% (left_x: 1 top_y: 802 width: 134 height: 47)

If I'm wrong, please correct me . To calculate mAP,you need predicted values and ground truth. In our case,the values are something like that which is coordinates of bounding box; 00082 0.999969 504.637390 651.370789 610.118347 736.534363.

Hi, I assume that you would like to train the model or validate the detector. However the function for multiple image procession in this issue (also this post) is only for PREDICT, rather train_detect or validate_predict. So its totally different. Namely, in the PREDICT function, we only detect object in an image using existed model. We do not train model. We do not validate a model.

srhtyldz commented 5 years ago

I added this function in the source code and resolve this problem with command:

./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch ./in_images/ ./out_images/ >./results.txt

Parameter explain:

  • The input images are: ./in_images/
  • The output images are: ./out_images/
  • The detection classes with percentage is saved in: ./results.txt

To reach this, you need to replace the attached detector.c into ./src/ folder and re-make the AlexeyAB darknet.

Detail process:

  1. Install the AlexeyAB/darknet, see: github link. The darknet is installed in the folder: darknet/
  2. Replace the darknet/src/detector.c with the detector.c in attached. detector.c.zip
  3. Make the project with command in darknet/ folder: make
  4. If you have already did the make, you may do re-make with commands: clean make

You may still do for one image with: ./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights ./data/dog.jpg Any questions please let me know. vincent.gong7[at]gmail.com Best Regards, Vincent

I think this is worked for me but still not sure "Not compiled with OpenCV, saving to ./data/output/person_and_bike_092.png.png instead Not compiled with OpenCV, saving to ./data/output/person_and_bike_014.png.png instead Not compiled with OpenCV, saving to ./data/output/crop001688.png.png instead " when the script is run, the output is like that. Does it say that opencv is not installed that's why compiled ? could you please light me up for that ?

The same printed in my side. I think it means the OpenCV is turned off (either because it is not installed or because it is not turned on). The result should be not affected.

I have one more question.Can we get coordinates of detected images to calculate the mAP ? I think that the result text file only contains the percentage of guess.How can we get that ? Do you have a suggestion or help ?

May I know the definition of mAP you referred here. Is it the average percentage of all those guess (%)? What is the coordinates? is it the bounding box of the object detected on the image? something like: car: 93% (left_x: 1 top_y: 802 width: 134 height: 47)

Taha

I added this function in the source code and resolve this problem with command:

./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch ./in_images/ ./out_images/ >./results.txt

Parameter explain:

  • The input images are: ./in_images/
  • The output images are: ./out_images/
  • The detection classes with percentage is saved in: ./results.txt

To reach this, you need to replace the attached detector.c into ./src/ folder and re-make the AlexeyAB darknet.

Detail process:

  1. Install the AlexeyAB/darknet, see: github link. The darknet is installed in the folder: darknet/
  2. Replace the darknet/src/detector.c with the detector.c in attached. detector.c.zip
  3. Make the project with command in darknet/ folder: make
  4. If you have already did the make, you may do re-make with commands: clean make

You may still do for one image with: ./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights ./data/dog.jpg Any questions please let me know. vincent.gong7[at]gmail.com Best Regards, Vincent

I think this is worked for me but still not sure "Not compiled with OpenCV, saving to ./data/output/person_and_bike_092.png.png instead Not compiled with OpenCV, saving to ./data/output/person_and_bike_014.png.png instead Not compiled with OpenCV, saving to ./data/output/crop001688.png.png instead " when the script is run, the output is like that. Does it say that opencv is not installed that's why compiled ? could you please light me up for that ?

The same printed in my side. I think it means the OpenCV is turned off (either because it is not installed or because it is not turned on). The result should be not affected.

I have one more question.Can we get coordinates of detected images to calculate the mAP ? I think that the result text file only contains the percentage of guess.How can we get that ? Do you have a suggestion or help ?

May I know the definition of mAP you referred here. Is it the average percentage of all those guess (%)? What is the coordinates? is it the bounding box of the object detected on the image? something like: car: 93% (left_x: 1 top_y: 802 width: 134 height: 47)

If I'm wrong, please correct me . To calculate mAP,you need predicted values and ground truth. In our case,the values are something like that which is coordinates of bounding box; 00082 0.999969 504.637390 651.370789 610.118347 736.534363.

Hi, I assume that you would like to train the model or validate the detector. However the function for multiple image procession in this issue (also this post) is only for PREDICT, rather train_detect or validate_predict. So its totally different. Namely, in the PREDICT function, we only detect object in an image using existed model. We do not train model. We do not validate a model.

Thanks for explanation.I'm trying to find out how my training fits the model and test the model.

rrrtype commented 5 years ago

Updated: Dec 16, 2018 I added this function in the source code and resolve this problem with command:

./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch ./in_images/ ./out_images/ >./results.txt

Parameter explain:

  • The input images are: ./in_images/
  • The output images are: ./out_images/
  • The detection classes with percentage is saved in: ./results.txt

To reach this, you need to replace the attached detector.c into ./src/ folder and re-make the AlexeyAB darknet.

Detail process:

  1. Install the AlexeyAB/darknet, see: github link. The darknet is installed in the folder: darknet/
  2. Replace the darknet/src/detector.c with the detector.c: https://github.com/vincentgong7/AlexeyAB_darknet/blob/master/detector.c
  3. Make the project with command in darknet/ folder: make
  4. If you have already did the make, you may do re-make with commands: clean make

You may still do for one image with: ./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights ./data/dog.jpg

Any questions please let me know. vincent.gong7[at]gmail.com

Best Regards, Vincent

Thank you for your improvement! When I executed the make command exactly as you say, I got an error like the following. ./src/detector.c:46:6: error: conflicting types for 'train_detector'   void train_detector (char datacfg, char cfgfile, char weightfile, int gpus, compilation terminated due to - Wfatal - errors. Makefile: 136: Failed with recipe for target 'obj / detector.o' make: *** [obj / detector.o] Error 1

zzks commented 5 years ago

can i inference images by batch? is it faster than one by one?

srhtyldz commented 5 years ago

dont_show supposed to not show the output of training ,right? I still see the output.Is this related with cuda version ? @AlexeyAB

ahmadfaizan1990 commented 5 years ago

i am training yolov3-tiny and every time my training goes wrong either during training or after training it won't detect the object correctly. My class of interest is "person" and i tried different datasets like "Caltech", "INRIA" and my on generated dataset but i don't know what is wrong. i just wanted to know during training should i put test images as well in the same images folder because there is test.txt file associated to that and i don't know how to handle test.txt file

ahmadfaizan1990 commented 5 years ago

i am training yolov3-tiny and every time my training goes wrong either during training or after training it won't detect the object correctly. My class of interest is "person" and i tried different datasets like "Caltech", "INRIA" and my on generated dataset but i don't know what is wrong. i just wanted to know during training should i put test images as well in the same images folder because there is test.txt file associated to that and i don't know how to handle test.txt file @AlexeyAB

AlexeyAB commented 5 years ago

@ahmadfaizan1990 Follow this manual to train your own model: https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects

Also check your dataset by using: https://github.com/AlexeyAB/Yolo_mark

vincentgong7 commented 5 years ago

Hi geeks,

I just revised the code for batch image process for the newest version of darknet_ab. Currently I'm testing my code. I'll upload & update it today in about 3 hours. Just in case you want to know. Sorry for the delay these days, crazy busy.

BR, Vincent

vincentgong7 commented 5 years ago

Updated: Dec 16, 2018 I added this function in the source code and resolve this problem with command:

./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights batch ./in_images/ ./out_images/ >./results.txt

Parameter explain:

  • The input images are: ./in_images/
  • The output images are: ./out_images/
  • The detection classes with percentage is saved in: ./results.txt

To reach this, you need to replace the attached detector.c into ./src/ folder and re-make the AlexeyAB darknet.

Detail process:

  1. Install the AlexeyAB/darknet, see: github link. The darknet is installed in the folder: darknet/
  2. Replace the darknet/src/detector.c with the detector.c: https://github.com/vincentgong7/AlexeyAB_darknet/blob/master/detector.c
  3. Make the project with command in darknet/ folder: make
  4. If you have already did the make, you may do re-make with commands: clean make

You may still do for one image with: ./darknet detector test cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights ./data/dog.jpg Any questions please let me know. vincent.gong7[at]gmail.com Best Regards, Vincent

Thank you for your improvement! When I executed the make command exactly as you say, I got an error like the following. ./src/detector.c:46:6: error: conflicting types for 'train_detector'   void train_detector (char datacfg, char cfgfile, char weightfile, int gpus, compilation terminated due to - Wfatal - errors. Makefile: 136: Failed with recipe for target 'obj / detector.o' make: *** [obj / detector.o] Error 1

Fixed. please see: https://github.com/pjreddie/darknet/issues/723#issuecomment-446801283

vincentgong7 commented 5 years ago

This problem is updated and fixed. Please refer to https://github.com/pjreddie/darknet/issues/723#issuecomment-446801283

ahmadfaizan1990 commented 5 years ago

When I change some convolutional layers in cfg file according to my dataset it will give me an error.

error Last layer must detection layer.

How to solve this problem @alaxyab

Get Outlook for Androidhttps://aka.ms/ghei36


From: Vincent Gong notifications@github.com Sent: Sunday, March 17, 2019 9:04:36 AM To: pjreddie/darknet Cc: ahmadfaizan1990; Mention Subject: Re: [pjreddie/darknet] Run YoloV3 detections on thousands of images and save outputs? (#723)

This problem is updated and fixed. Please refer to #723 (comment)https://github.com/pjreddie/darknet/issues/723#issuecomment-446801283

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/pjreddie/darknet/issues/723#issuecomment-473605935, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlcUQ0tSs2EIaYMlnbkT-JNkIJ5m32RCks5vXZSkgaJpZM4Ten8t.

ahmadfaizan1990 commented 5 years ago

When I change some convolutional layers in cfg file according to my dataset it will give me an error.

error Last layer must detection layer.

How to solve this problem @AlexeyAB