darknet icon indicating copy to clipboard operation
darknet copied to clipboard

How to detect smaller objects with custom object datasets

Open praneeth0609 opened this issue 4 years ago • 28 comments

hello... Currently, I'm working on custom object detection like birds, etc. I need to detect small objects also. but am not able to detect small objects. To get detect small objects, what I need to do. Here are my questions:

  1. How many images required per class ? (am using 2 classes.)
  2. For smaller object detection what I have to do ?
  3. even the object is very small in the frame. it should be detected . for this any suggestions?
  4. If we take one bird as an example, how many images required for specific angle of bird (front, back, up, bottom) ?
  5. what is the minimum object size that i can detect using yolo. ?
  6. For smaller object detections, what changes I have to do to my custom object dataset ?
  7. Any suggestions for improving the mAP ?

praneeth0609 avatar Aug 06 '20 09:08 praneeth0609

@praneeth0609 I am also working currently on a project to detect objects which are even smaller than mentioned by you. The objects are small stones, nuts, bolts, screws etc. I am also facing the same issue that I have trained Yolov3 and Yolov4 on my custom dataset but not able to get good results. So any solution?

Farjad3253 avatar Aug 06 '20 11:08 Farjad3253

@praneeth0609 @Farjad3253

https://github.com/AlexeyAB/darknet

check this repo and search "small object" , he explained how to train for small objects, smaller than 16 x 16.

MuhammadAsadJaved avatar Aug 07 '20 07:08 MuhammadAsadJaved

@MuhammadAsadJaved . Yes I have checked that repo but not getting good results!

m-ali-awan avatar Aug 07 '20 07:08 m-ali-awan

@MuhammadAsadJaved , thanks for your reply. I have checked https://github.com/AlexeyAB/darknet and i followed those instructions. can you give some suggestions on below quires:

  1. How many images required per class for proper detection and classification?
  2. If we take one bird as an example, how many images required for a specific angle of bird(front, back, up, bottom) ?
  3. Any suggestions for improving the mAP ?

praneeth0609 avatar Aug 07 '20 09:08 praneeth0609

hello @pjreddie @MuhammadAsadJaved I have a camera with 30X optical Zoom, and I want to detect birds, which are at long distances. give me some suggestions:

  1. for the above scenario which type of images I have to take for training. a. high resolution or low resolution. b. what should be the bird size in training images.
  2. I'm using yolo object detection algorithm. please give me some suggestions.

praneeth0609 avatar Aug 08 '20 06:08 praneeth0609

@MuhammadAsadJaved @praneeth0609 . I have tried the training of model for smaller objects as specified on https://github.com/AlexeyAB/darknet. But still not getting good results on small objects like bolts, screws, stones etc. Kindly solve this issue?

Farjad3253 avatar Aug 10 '20 03:08 Farjad3253

I haven't worked with this problem, I just saw this information so shared with you.

On Mon, Aug 10, 2020 at 11:02 AM Farjad3253 [email protected] wrote:

@MuhammadAsadJaved https://github.com/MuhammadAsadJaved @praneeth0609 https://github.com/praneeth0609 . I have tried the training of model for smaller objects as specified on https://github.com/AlexeyAB/darknet. But still not getting good results on small objects like bolts, screws, stones etc. Kindly solve this issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pjreddie/darknet/issues/2256#issuecomment-671142812, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG4GR5B4LYS6MUYXG3MASTTR75PLVANCNFSM4PWMJYDQ .

MuhammadAsadJaved avatar Aug 10 '20 06:08 MuhammadAsadJaved

When you're going to detect the object, try to set higher values on width and height on your cfg file. I managed to detect really small objects on a image 4000x3000 with the width and height on 2560.

Tuumix avatar Aug 16 '20 01:08 Tuumix

@Tuumix . What was the input size which you specified in the cfg file?

Farjad3253 avatar Aug 17 '20 02:08 Farjad3253

@Farjad3253 for training it was 768 and for detection 2560

Tuumix avatar Aug 17 '20 02:08 Tuumix

@Tuumix . Ok you mean that for training it was 768x768 and while testing you used 2560x2569? Is it so?

Farjad3253 avatar Aug 17 '20 02:08 Farjad3253

Yes, for training I cropped the image in 768x768x and for detection I use the full resolution image but the cfg file I used 2560x2560

Tuumix avatar Aug 17 '20 02:08 Tuumix

@Tuumix . Ok I got your point that while you were training you specified the resolution as 768x768 in .cfg file!

Farjad3253 avatar Aug 17 '20 03:08 Farjad3253

Yees, sorry if my explanation was a little bit confusing haha

Tuumix avatar Aug 17 '20 03:08 Tuumix

@Tuumix . No problem dear! Atleast you tried to help us. Thanks!

Farjad3253 avatar Aug 17 '20 03:08 Farjad3253

Yes, for training I cropped the image in 768x768x and for detection I use the full resolution image but the cfg file I used 2560x2560

@Tuumix thank you for your suggestion. how you did the crop operation. is it cropping the object or resizing the full image to 768x768. can you share your .cfg file here. it will be more helpful.

praneeth0609 avatar Aug 17 '20 04:08 praneeth0609

@praneeth0609 I cropped the object to 768x768.

Tuumix avatar Aug 25 '20 00:08 Tuumix

@Tuumix thank you for your replay. I want to know some details regarding the training of yolov4. present I'm training custom data using yolov4. Screenshot (74) this is how I'm getting the loss and mAP graph. can you clarify the bellow questions?

  1. How many iterations need to perform(according to the above graph for better results)?
  2. what should I do to maintain constant mAP?

praneeth0609 avatar Aug 25 '20 12:08 praneeth0609

@Tuumix @Farjad3253

  1. Currently, I'm using a camera for custom object detection using the yolov4 algorithm, which has 1920x1080 pixels resolution. Now I want to change my camera. the specifications of both the new camera and old camera are similar. can I use the same weight files and the same training methods with the new camera?
  2. is there any effects or changes in detection with different cameras? (using yolov4 object detection)

praneeth0609 avatar Sep 04 '20 09:09 praneeth0609

Hi @Tuumix

If I understand correctly, your training network size was 768x768, and you cropped your training images to that resolution.

During detection, your input image resolution is 4000x3000 and forwarded to detection network of 2560x2560.

  1. Did you scale down the evaluation image size of 4000x3000 to network size of 2560x2560, or did you slide the evaluation image in the size of 2560x2560 (and probably 200px strive for overlaps) before forward to the network for detection?

  2. Regarding training network, I also found in https://github.com/AlexeyAB/darknet/blob/master/README.md#how-to-improve-object-detection that says

    increase network resolution in your .cfg-file (height=608, width=608 or any value multiple of 32) - it will increase precision

    Do you think you would get better accuracy if your training size was higher than 768?

    We have a similar use case to detect small objects (~200px) in a 4k image. We bumped the training size to 1056x1056 (the largest training resolution we can fit with 16GB GPU RAM), but the detection accuracy of small objects is not very, thus investigating what other parameters (training network size, training image size; detection network size, detection image size).

Thanks!

kangks avatar Sep 09 '20 02:09 kangks

If we have to use two different GPU s 2060 and 2070, for OpenCV dnn or darkent , do we need to use separate versions of cuda and CUDNN...? If we use two separate versions can I use them whenever I need or will the older version will be overwritten by the new version?

praneeth0609 avatar Sep 27 '20 13:09 praneeth0609

You can use same cuda and cudnn.

  • you can also install multiple cuda and cuDNN and just chanage ~/.bashrc to mention the cuda and cudnn version you are willing to use. Then version in the bashrc will be used.

On Sun, Sep 27, 2020 at 9:41 PM praneeth0609 [email protected] wrote:

If we have to use two different GPU s 2060 and 2070, for OpenCV dnn or darkent , do we need to use separate versions of cuda and CUDNN...? If we use two separate versions can I use them whenever I need or will the older version will be overwritten by the new version?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pjreddie/darknet/issues/2256#issuecomment-699637218, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG4GR5DNCNVJK2MO54ANXPLSH46JTANCNFSM4PWMJYDQ .

MuhammadAsadJaved avatar Sep 27 '20 14:09 MuhammadAsadJaved

@kangks can you share the cfg file for training with 1056x1056

research-boy avatar Oct 20 '20 09:10 research-boy

@MuhammadAsadJaved currently I'm using intel i7 9th gen, Geforce 2060 6 GB GPU, Linux os, and am trying to detect the custom objects using yolov4, but am getting Low processing rate. can I upgrade to 2070 8 GB, if I can..? what are the advantages of 2070 over 2060. can you suggest the best GPU for Yolo v4 object detection with a decent frame rate ...?

praneeth0609 avatar Nov 25 '20 16:11 praneeth0609

I have images that have a height of around 2000 and a width around 1500. I'm using 4-tesla T4 GPU. When I use height width 1024 or even 608 for batch size = 64 and subdivision = 16. I get out of memory cuda error.

My question is I want to train yolov4 for higher resolution at batch size=64 and subdivision=16 so what kind of GPU I need, how much RAM do I need, How much GPU I need? OR any other hard ware configure I have to follow for such kind of training?

Thank You

meetyogi98 avatar May 31 '21 11:05 meetyogi98

hello... Currently, I'm working on custom object detection like birds, etc. I need to detect small objects also. but am not able to detect small objects. To get detect small objects, what I need to do. Here are my questions:

  1. How many images required per class ? (am using 2 classes.)
  2. For smaller object detection what I have to do ?
  3. even the object is very small in the frame. it should be detected . for this any suggestions?
  4. If we take one bird as an example, how many images required for specific angle of bird (front, back, up, bottom) ?
  5. what is the minimum object size that i can detect using yolo. ?
  6. For smaller object detections, what changes I have to do to my custom object dataset ?
  7. Any suggestions for improving the mAP ?

did you get good results? i am trying to set a cfg file for small objects as well, tennis table balls, and i was wondering if you would have any advice

tomer-erez avatar Aug 12 '22 07:08 tomer-erez

@AhlemKaabi Thank you for sharing the proper resource here.

praneeth0609 avatar Feb 13 '23 10:02 praneeth0609