ultralytics / yolov5

YOLOv5 šŸš€ in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
51.09k stars 16.42k forks source link

Failing at small detection !! #13401

Open Manueljohnson063 opened 2 weeks ago

Manueljohnson063 commented 2 weeks ago

Search before asking

Question

Thank you for the great repository!

Iā€™m currently working on a driver smoking detection project. I have trained my model with nearly 5,000 images; however, it mistakenly identifies light glare as a cigarette, due to the similarity in appearance. My model has only one class, labeled "cigarette." Could you suggest some modifications to improve its accuracy?@Glenn

Additional

No response

UltralyticsAssistant commented 2 weeks ago

šŸ‘‹ Hello @Manueljohnson063, thank you for your interest in YOLOv5 šŸš€!

For improving the accuracy of your model, especially in distinguishing similar-looking objects, you might consider the following approaches:

  1. Dataset Enhancement: Increase your dataset, particularly with more examples of correctly and incorrectly identified objects. Ensuring a variety of lighting conditions and angles can help.

  2. Data Augmentation: Use techniques such as adding noise, adjusting brightness/contrast, and flipping images to enhance your training data.

  3. Hyperparameter Tuning: Experiment with different hyperparameters to see if they bring improvements in accuracy.

  4. Model Architecture: Try different model sizes or architectures within YOLOv5 to find the best fit for your task.

  5. Loss Functions: Modify loss functions to better penalize the misclassification errors specific to your problem.

If this is a šŸ› Bug Report, please provide a minimum reproducible example to help us debug it.

This is an automated response, and an Ultralytics engineer will also assist you soon. If you have further questions or need more detailed assistance, please feel free to reply with additional information, such as your dataset examples and training logs.

And don't miss out on the possibilities with the latest YOLOv8 šŸ†• for potentially enhanced performance in your project! Check out our docs for more info.

Happy experimenting šŸ”!

pderrenger commented 2 weeks ago

@Manueljohnson063 to improve accuracy, consider increasing your dataset size with more diverse images, using data augmentation to enhance variability, and adjusting the confidence threshold to reduce false positives. You might also try training with a higher resolution or using a larger model like YOLOv5x for better feature extraction.

Manueljohnson063 commented 17 hours ago

Hai ,I have a yolov5s model downloaded from opensource.when i try to export it i am facing error `` python export.py --weights /home/vkchlt0616/Downloads/face_detection_yolov5s.pt --include onnx --opset=11 --imgsz 640 --batch-size 1 __export: data=data/coco128.yaml, weights=['/home/vkchlt0616/Downloads/face_detection_yolov5s.pt'], imgsz=[320], batch_size=1, device=cpu, half=False, inplace=False, keras=False, optimize=False, int8=False, per_tensor=False, dynamic=False, cache=, simplify=False, mlmodel=False, opset=11, verbose=False, workspace=4, nms=False, agnostic_nms=False, topk_per_class=100, topk_all=100, iou_thres=0.45, conf_thres=0.25, include=['onnx'] YOLOv5 šŸš€ v7.0-385-gb968b2d7 Python-3.8.19 torch-1.8.0 CPU

Fusing layers... newYOLOv5s summary: 224 layers, 7053910 parameters, 0 gradients Traceback (most recent call last): File "export.py", line 1546, in main(opt) File "export.py", line 1541, in main run(vars(opt)) File "/home/vkchlt0616/.local/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, *kwargs) File "export.py", line 1407, in run y = model(im) # dry runs File "/home/vkchlt0616/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(input, kwargs) File "/home/vkchlt0616/DOMS/smokingDet/yolov5/models/yolo.py", line 270, in forward return self._forward_once(x, profile, visualize) # single-scale inference, train File "/home/vkchlt0616/DOMS/smokingDet/yolov5/models/yolo.py", line 169, in _forward_once x = m(x) # run File "/home/vkchlt0616/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, kwargs) File "/home/vkchlt0616/DOMS/smokingDet/yolov5/models/common.py", line 356, in forward return self.conv(torch.cat((x[..., ::2, ::2], x[..., 1::2, ::2], x[..., ::2, 1::2], x[..., 1::2, 1::2]), 1)) File "/home/vkchlt0616/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, *kwargs) File "/home/vkchlt0616/DOMS/smokingDet/yolov5/models/common.py", line 91, in forward_fuse return self.act(self.conv(x)) File "/home/vkchlt0616/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(input, kwargs) File "/home/vkchlt0616/.local/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 399, in forward return self._conv_forward(input, self.weight, self.bias) File "/home/vkchlt0616/.local/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 395, in _conv_forward return F.conv2d(input, weight, bias, self.stride, RuntimeError: Given groups=1, weight of size [32, 12, 3, 3], expected input[1, 48, 160, 160] to have 12 channels, but got 48 channels instead__

@glenn-jocher

But the model is detecting face properly from web cam .The issue only come during exporting to onnx.Please give me the suggestion....