ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.83k stars 16.37k forks source link

YOLO V5 for custom training and detection #2983

Closed bugmany closed 3 years ago

bugmany commented 3 years ago

❔Question

1.train: python3 train.py --data custom.yaml --cfg yolov5s.yaml --weights weights/yolov5s.pt --epochs 5 train: Scanning 'data/custom/labels/train.cache' images and labels... 6 found, 0 missing, 0 empty, 0 corrupted: 100%|█| 6/6 [0 val: Scanning 'data/custom/labels/train.cache' images and labels... 6 found, 0 missing, 0 empty, 0 corrupted: 100%|█| 6/6 [00:Plotting labels... val: Scanning 'data/custom/labels/train.cache' images and labels... 6 found, 0 missing, 0 empty, 0 corrupted: 100%|█| 6/6 [00:

autoanchor: Analyzing anchors... anchors/target = 3.86, Best Possible Recall (BPR) = 1.0000 Image sizes 640 train, 640 test Using 4 dataloader workers Logging results to runs/train/exp3 Starting training for 5 epochs...

 Epoch   gpu_mem       box       obj       cls     total    labels  img_size
   0/4        0G    0.1254   0.04242   0.08415     0.252        37       640: 100%|█████████| 1/1 [00:05<00:00,  5.10s/it]
           Class      Images      Labels           P           R      mAP@.5  mAP@.5:.95: 100%|█| 1/1 [00:03<00:00,  3.89s
             all           6           0           0           0           0           0

Images sizes do not match. This will causes images to be display incorrectly in the UI.

 Epoch   gpu_mem       box       obj       cls     total    labels  img_size
   1/4        0G    0.1246   0.04416   0.08551    0.2543        42       640: 100%|█████████| 1/1 [00:06<00:00,  6.93s/it]
           Class      Images      Labels           P           R      mAP@.5  mAP@.5:.95: 100%|█| 1/1 [00:03<00:00,  3.41s
             all           6           0           0           0           0           0

 Epoch   gpu_mem       box       obj       cls     total    labels  img_size
   2/4        0G    0.1251   0.05065   0.08903    0.2648        46       640: 100%|█████████| 1/1 [00:05<00:00,  5.33s/it]
           Class      Images      Labels           P           R      mAP@.5  mAP@.5:.95: 100%|█| 1/1 [00:03<00:00,  3.72s
             all           6           0           0           0           0           0

 Epoch   gpu_mem       box       obj       cls     total    labels  img_size
   3/4        0G   0.07845   0.04337   0.05434    0.1762        36       640: 100%|█████████| 1/1 [00:05<00:00,  5.19s/it]
           Class      Images      Labels           P           R      mAP@.5  mAP@.5:.95: 100%|█| 1/1 [00:03<00:00,  3.28s
             all           6           0           0           0           0           0

 Epoch   gpu_mem       box       obj       cls     total    labels  img_size
   4/4        0G    0.1235    0.0542   0.08529     0.263        54       640: 100%|█████████| 1/1 [00:04<00:00,  4.73s/it]
           Class      Images      Labels           P           R      mAP@.5  mAP@.5:.95: 100%|█| 1/1 [00:03<00:00,  3.22s
             all           6           0           0           0           0           0

5 epochs completed in 0.014 hours.

Optimizer stripped from runs/train/exp3/weights/last.pt, 14.5MB Optimizer stripped from runs/train/exp3/weights/best.pt, 14.5MB Images sizes do not match. This will causes images to be display incorrectly in the UI.

wandb: Waiting for W&B process to finish, PID 79757 wandb: Program ended successfully.

2.detect: python3 detect.py --source data/images --weights weights/best.pt --conf 0.25 Fusing layers... Model Summary: 224 layers, 7113244 parameters, 0 gradients, 16.5 GFLOPS image 1/2 /Users/home/dev/yolov5/data/images/bus.jpg: 640x480 Done. (0.182s) image 2/2 /Users/home/dev/yolov5/data/images/zidane.jpg: 384x640 Done. (0.148s) Results saved to runs/detect/exp2 Done. (0.400s)

at last, i did not detect anything information with my train models ("best.pt"), can anyone help me?

Additional context

github-actions[bot] commented 3 years ago

👋 Hello @bugmany, 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.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ 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), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 3 years ago

@bugmany 👋 Hello! Thanks for asking about improving training results. Most of the time good results can be obtained with no changes to the models or training settings, provided your dataset is sufficiently large and well labelled. If at first you don't get good results, there are steps you might be able to take to improve, but we always recommend users first train with all default settings before considering any changes. This helps establish a performance baseline and spot areas for improvement.

If you have questions about your training results we recommend you provide the maximum amount of information possible if you expect a helpful response, including results plots (train losses, val losses, P, R, mAP), PR curve, confusion matrix, training mosaics, test results and dataset statistics images such as labels.png. All of these are located in your project/name directory, typically yolov5/runs/train/exp.

We've put together a full guide for users looking to get the best results on their YOLOv5 trainings below.

Dataset

COCO Analysis

Model Selection

Larger models like YOLOv5x will produce better results in nearly all cases, but have more parameters and are slower to run. For mobile applications we recommend YOLOv5s/m, for cloud or desktop applications we recommend YOLOv5l/x. See our README table for a full comparison of all models.

To start training from pretrained weights simply pass the name of the model to the --weights argument. Models download automatically from the latest YOLOv5 release.

python train.py --data custom.yaml --weights yolov5s.pt
                                             yolov5m.pt
                                             yolov5l.pt
                                             yolov5x.pt

YOLOv5 Models

Training Settings

Before modifying anything, first train with default settings to establish a performance baseline. A full list of train.py settings can be found in the train.py argparser.

Further Reading

If you'd like to know more a good place to start is Karpathy's 'Recipe for Training Neural Networks', which has great ideas for training that apply broadly across all ML domains: http://karpathy.github.io/2019/04/25/recipe/

bugmany commented 3 years ago

hello @github-actions and @glenn-jocher, thanks for yours reply,

here is W&B info: debug.log debug-internal.log

reproduce this issue: git path: https://github.com/bugmany/yolov5_bm.git train command: python3 train.py --data custom.yaml --cfg yolov5s.yaml --weights weights/yolov5s.pt --img 640 --epochs 5 detect command: python3 detect.py --source data/images --weights weights/best.pt --conf 0.25

thanks a lot.

bugmany commented 3 years ago

I 've solved it by increased epochs times.