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

Slender object detection only has low PR and mAP #4030

Closed
Yanhui-He opened this issue Jul 17, 2021 · 7 comments
Closed

Slender object detection only has low PR and mAP #4030

Yanhui-He opened this issue Jul 17, 2021 · 7 comments
Labels
question Further information is requested Stale

Comments

@Yanhui-He
Copy link

Yolov5 is a wonderful work in object detection. I used it in pedestrian detection and vehicle detection, which has great pweformence. However, when I try to use yolov5 to detect the pole-like object, such as light pole, traffic pole, wire pole, and sign pole, the model has a poor performence.

Note: I only want to detect single class that is pole.

I have changed the ratio of width and height in ddateset.py (the max ar_thr is 63 in my own dataset):
def box_candidates(box1, box2, wh_thr=1, ar_thr=100, area_thr=0.1, eps=1e-16):

On the other hand, the custom data set has more than 9000 pole labels. So I think the dataset is enough to train the model.
The result is: Precison = 68.8, Recall = 36.0, mAP@.5 = 26.8.

(I use yolov5l6.yaml, the conf is 0.25 when I test the image.)

I also find a paper that report the slender detection: (https://arxiv.org/abs/2011.08529)

This problem has troubled me for a long time, please help me or give me some enlightenment.

@Yanhui-He Yanhui-He added the question Further information is requested label Jul 17, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Jul 17, 2021

👋 Hello @Yanhui-He, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

$ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

@glenn-jocher
Copy link
Member

@Yanhui-He you may need to relax the box candidate criteria here to allow higher aspect ratio labels. The default is 20, you could raise this to 100 for example for extremely thin objects:

def box_candidates(box1, box2, wh_thr=2, ar_thr=20, area_thr=0.1, eps=1e-16): # box1(4,n), box2(4,n)
# Compute candidate boxes: box1 before augment, box2 after augment, wh_thr (pixels), aspect_ratio_thr, area_ratio
w1, h1 = box1[2] - box1[0], box1[3] - box1[1]
w2, h2 = box2[2] - box2[0], box2[3] - box2[1]
ar = np.maximum(w2 / (h2 + eps), h2 / (w2 + eps)) # aspect ratio
return (w2 > wh_thr) & (h2 > wh_thr) & (w2 * h2 / (w1 * h1 + eps) > area_thr) & (ar < ar_thr) # candidates

@glenn-jocher
Copy link
Member

@Yanhui-He ah I see you already raise the limit. In this case you may simply need to train at higher resolution to capture more pixels in the short dimension, i.e. train at --img 1280 or 2560.

Remember also that YOLOv5 is designed for COCO-like objects, if your use case relies highly on high AR objects you may want to modify the convolutions in the C3 layers from 3x3 to alternating 1x9 and 9x1 for example.

@Yanhui-He
Copy link
Author

Yanhui-He commented Jul 26, 2021

@glenn-jocher I used --img-size 1472 to train the model, and test the model in 1920 resolution images. Moreover, I try to use DWConv to replace Conv module. However, the recall and mAP@.5 is less than 50%.

And I don't konw how to change the convolutions in the C3 layers. For example:
I changed the code in common.py class C3 module:

self.cv1 = Conv(c1, c_, 1, 1) >> self.cv1 = Conv(c1, c_, (9, 1), 1)

but that is wrong.

Oh, To improve the performence, I widen the pole's label width. (original label width * 2), which can improve the precision. Currently, the precision is 80% where the confidence is 0.5.

Meawhile, I changed the objectness in loss.py:

tobj[b, a, gj, gi] = (1.0 - self.gr) + self.gr * iou.detach().clamp(0).type(tobj.dtype) >> tobj[b, a, gj, gi] = 1.0

It can improve the object confidence when detecting and testing. Therefore, all of my result is testing in the 0.5 confidence.

@glenn-jocher
Copy link
Member

See CrossConv module as an example. You could update this to 5,1 and 1,5 for example

@Yanhui-He
Copy link
Author

Thanks for your reply. I will try to use the CrossConv in the C3 module.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 26, 2021

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

Access additional Ultralytics ⚡ resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

2 participants