ultralytics / yolov5

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

Train my Custom Data,But can not find the images and labels #2144

Closed Zeroh023 closed 3 years ago

Zeroh023 commented 3 years ago

❔Question

HI! I am trying to train my Custom Data.I followed the "Train Custom Data Tutorial" ,made the labels with lambllmg(label format is YOLO) .And I am sure I put all images and labels in right places. But while i start training , always got this error:

Scanning 'D:\yolo\yolov5-WBunderv5\Dateset\Score\image\train.cache' for images and labels... 0 found, 71 missing, 0 empty, 0 corrupted: 100%|██████████| 71/71 [00:00<?, ?it/s]

And this is the whole tip:

Using torch 1.7.1+cu110 CUDA:0 (GeForce GTX 1650, 4096MB)

Namespace(adam=False, batch_size=4, bucket='', cache_images=False, cfg='models/helmet.yaml', data='data/custom_data.yaml', device='0', epochs=10, evolve=False, exist_ok=False, global_rank=-1, hyp='data/hyp.scratch.yaml', image_weights=False, img_size=[640, 640], local_rank=-1, log_imgs=16, multi_scale=False, name='exp', noautoanchor=False, nosave=False, notest=False, project='runs/train', rect=False, resume=False, save_dir='runs\train\exp43', single_cls=False, sync_bn=False, total_batch_size=4, weights='weights/yolov5s.pt', workers=8, world_size=1) Start Tensorboard with "tensorboard --logdir runs/train", view at http://localhost:6006/ Hyperparameters {'lr0': 0.01, 'lrf': 0.2, 'momentum': 0.937, 'weight_decay': 0.0005, 'warmup_epochs': 3.0, 'warmup_momentum': 0.8, 'warmup_bias_lr': 0.1, 'box': 0.05, 'cls': 0.5, 'cls_pw': 1.0, 'obj': 1.0, 'obj_pw': 1.0, 'iou_t': 0.2, 'anchor_t': 4.0, 'fl_gamma': 0.0, 'hsv_h': 0.015, 'hsv_s': 0.7, 'hsv_v': 0.4, 'degrees': 0.0, 'translate': 0.1, 'scale': 0.5, 'shear': 0.0, 'perspective': 0.0, 'flipud': 0.0, 'fliplr': 0.5, 'mosaic': 1.0, 'mixup': 0.0}

             from  n    params  module                                  arguments                     

0 -1 1 3520 models.common.Focus [3, 32, 3]
1 -1 1 18560 models.common.Conv [32, 64, 3, 2]
2 -1 1 19904 models.common.BottleneckCSP [64, 64, 1]
3 -1 1 73984 models.common.Conv [64, 128, 3, 2]
4 -1 1 161152 models.common.BottleneckCSP [128, 128, 3]
5 -1 1 295424 models.common.Conv [128, 256, 3, 2]
6 -1 1 641792 models.common.BottleneckCSP [256, 256, 3]
7 -1 1 1180672 models.common.Conv [256, 512, 3, 2]
8 -1 1 656896 models.common.SPP [512, 512, [5, 9, 13]]
9 -1 1 1248768 models.common.BottleneckCSP [512, 512, 1, False]
10 -1 1 131584 models.common.Conv [512, 256, 1, 1]
11 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
12 [-1, 6] 1 0 models.common.Concat [1]
13 -1 1 378624 models.common.BottleneckCSP [512, 256, 1, False]
14 -1 1 33024 models.common.Conv [256, 128, 1, 1]
15 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
16 [-1, 4] 1 0 models.common.Concat [1]
17 -1 1 95104 models.common.BottleneckCSP [256, 128, 1, False]
18 -1 1 147712 models.common.Conv [128, 128, 3, 2]
19 [-1, 14] 1 0 models.common.Concat [1]
20 -1 1 313088 models.common.BottleneckCSP [256, 256, 1, False]
21 -1 1 590336 models.common.Conv [256, 256, 3, 2]
22 [-1, 10] 1 0 models.common.Concat [1]
23 -1 1 1248768 models.common.BottleneckCSP [512, 512, 1, False]
24 [17, 20, 23] 1 16182 models.yolo.Detect [1, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]] Model Summary: 283 layers, 7255094 parameters, 7255094 gradients, 16.8 GFLOPS

Transferred 362/370 items from weights/yolov5s.pt Optimizer groups: 62 .bias, 70 conv.weight, 59 other Scanning 'D:\yolo\yolov5-WBunderv5\Dateset\Score\image\train.cache' for images and labels... 0 found, 71 missing, 0 empty, 0 corrupted: 100%|██████████| 71/71 [00:00<?, ?it/s]Traceback (most recent call last): File "D:/yolo/yolov5-WBunderv5/train.py", line 491, in train(hyp, opt, device, tb_writer, wandb) File "D:/yolo/yolov5-WBunderv5/train.py", line 183, in train dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt, File "D:\yolo\yolov5-WBunderv5\utils\datasets.py", line 61, in create_dataloader dataset = LoadImagesAndLabels(path, imgsz, batch_size, File "D:\yolo\yolov5-WBunderv5\utils\datasets.py", line 377, in init assert nf > 0 or not augment, f'No labels found in {cache_path}. Can not train without labels. See {help_url}' AssertionError: No labels found in D:\yolo\yolov5-WBunderv5\Dateset\Score\image\train.cache. Can not train without labels. See https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data Scanning 'D:\yolo\yolov5-WBunderv5\Dateset\Score\image\train.cache' for images and labels... 0 found, 71 missing, 0 empty, 0 corrupted: 100%|██████████| 71/71 [00:00<?, ?it/s]

Additional context

Give me some advice ,thanks!

github-actions[bot] commented 3 years ago

👋 Hello @Zeroh023, 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

@Zeroh023 read the message:

Scanning 'D:\yolo\yolov5-WBunderv5\Dateset\Score\image\train.cache' for images and labels... 0 found, 71 missing, 0 empty, 0 corrupted: 100%|██████████| 71/71 [00:00<?, ?it/s]

Follow tutorial directions: https://docs.ultralytics.com/yolov5/tutorials/train_custom_data

Use correct formatting when pasting code: ```

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

roberthobblebottom commented 3 years ago

I too am getting this error, I have been following the Train-Custom-Data guide but I still having this problem. am I not suppose to put in the train/labels locaiton in the YAML data file?

glenn-jocher commented 3 years ago

@themissingCRAM follow the COCO128 example in the train custom data tutorial. Also see the Colab notebook for an easy training example. https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb

masterpeas commented 2 years ago

Rename the training data worked for me. Ref:https://github.com/ultralytics/yolov5/issues/4460

glenn-jocher commented 10 months ago

@masterpeas glad to hear that renaming the training data worked for you! Remember to keep an eye on the file naming conventions as described in the YOLOv5 documentation to ensure smooth processing in the future. If you have any more questions or need further assistance, feel free to ask!