ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.25k stars 3.45k forks source link

How to detect long, but thin (1-3 pixel wide) objects such us lines and cracks #582

Closed davidkadlecek closed 5 years ago

davidkadlecek commented 5 years ago

I started using your yolov3 framework to detect cracks on metal drilling parts. I would appreciate some hints on how to fine tune the the yolov3 network and its hyperparameters to be able detecting long, but very thin defects.

I have 4k x 3k images that I resized to 1.6k x 1.2k and than cutted to 608x608, 416x416 and 256x256 tiles containing the cracks. The cracks are quite visible with human eye. I have a set of 1000 real images and 4000 artificial images (cracks generated using tent map and some augmentation)

I am still after 200 epochs on mAP=0 on yolov3-tiny.cfg and yolov3-spp.cfg. I am guessing that the architecture needs to be reconfigured slightly to be able detecting long, but couple of pixels wide defect.

I would very appreciate any recommendation.

glenn-jocher commented 5 years ago

You want to remove constraints from the labels and the inference outputs. These constraints reject objects that are too tiny or narrow (too high aspect ratio) to be meaningfully detected.

During data loading and augmentation: https://github.com/ultralytics/yolov3/blob/8d1ab548c11426ae810efead6ec791c4cbd1b174/utils/datasets.py#L700-L710

During NMS: https://github.com/ultralytics/yolov3/blob/8d1ab548c11426ae810efead6ec791c4cbd1b174/utils/utils.py#L443