WongKinYiu / yolov9

Implementation of paper - YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information
GNU General Public License v3.0
8.95k stars 1.41k forks source link

No labels found in DATASET_PATH/train.cache meanwhile training Pascal VOC Dataset #228

Closed barzan-hayati closed 7 months ago

barzan-hayati commented 7 months ago

I want to train yolov9 for Pascal VOC dataset. So I convert .xml files to .txt format.

By running this command to do training :

python train.py --workers 8 --device 0 --batch 16 --img 640 --epochs 500 --data PATH/yolov9/data.yaml --cfg PATH/yolov9/models/detect/yolov9.yaml --weights PATH/yolov9-e.pt --name yolov9-e --hyp PATH/yolov9/data/hyps/hyp.scratch-high.yaml --min-items 0 --close-mosaic 15

I got this error:

AMP: checks passed ✅
optimizer: SGD(lr=0.01) with parameter groups 230 weight(decay=0.0), 247 weight(decay=0.0005), 245 bias
train: Scanning PATH/VOC_2012_2007/train.cache... 0 images, 15495 backgrounds, 0 corrupt: 100%|██████
Traceback (most recent call last):
  File "train.py", line 634, in <module>
    main(opt)
  File "train.py", line 528, in main
    train(opt.hyp, opt, device, callbacks)
  File "train.py", line 193, in train
    min_items=opt.min_items)
  File "PATH/yolov9/utils/dataloaders.py", line 133, in create_dataloader
    prefix=prefix)
  File "PATH/yolov9/utils/dataloaders.py", line 498, in __init__
    assert nf > 0 or not augment, f'{prefix}No labels found in {cache_path}, can not start training. {HELP_URL}'
AssertionError: train: No labels found in PATH/VOC_2012_2007/train.cache, can not start training. See https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data

It seems that I should have a train.cache file - maybe also test.cache and validation.cache files. How could I generate them?

Youho99 commented 7 months ago

What is your dataset architecture ? What is your data.yaml ?

barzan-hayati commented 7 months ago

What is your dataset architecture ? What is your data.yaml ?

I have forgotten to create .txt files.

sai-kiran7 commented 4 months ago

Hi @barzan-hayati , I am facing the same issue can u please check this once.

My directory structue is like this

-Data

My Images are in '.png' and labels in '.txt' format.

I am getting this error

2024-06-26 08:25:26.878756: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered 2024-06-26 08:25:26.878818: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered 2024-06-26 08:25:26.880215: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered 2024-06-26 08:25:26.887670: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2024-06-26 08:25:28.072517: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT train: weights=/content/yolov9-e.pt, cfg=/content/yolov9/models/detect/yolov9.yaml, data=/content/yolov9/data.yaml, hyp=/content/yolov9/data/hyps/hyp.scratch-high.yaml, epochs=50, batch_size=4, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=False, evolve=None, bucket=, cache=None, image_weights=False, device=0, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=runs/train, name=exp, exist_ok=False, quad=False, cos_lr=False, flat_cos_lr=False, fixed_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, seed=0, local_rank=-1, min_items=0, close_mosaic=0, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest YOLOv5 🚀 1e33dbb Python-3.10.12 torch-2.3.0+cu121 CUDA:0 (Tesla T4, 15102MiB)

hyperparameters: lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, cls_pw=1.0, dfl=1.5, obj_pw=1.0, iou_t=0.2, anchor_t=5.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.9, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.15, copy_paste=0.3 ClearML: run 'pip install clearml' to automatically track, visualize and remotely train YOLO 🚀 in ClearML Comet: run 'pip install comet_ml' to automatically track and visualize YOLO 🚀 runs in Comet TensorBoard: Start with 'tensorboard --logdir runs/train', view at http://localhost:6006/ Overriding model.yaml nc=80 with nc=3

             from  n    params  module                                  arguments                     

0 -1 1 0 models.common.Silence []
1 -1 1 1856 models.common.Conv [3, 64, 3, 2]
2 -1 1 73984 models.common.Conv [64, 128, 3, 2]
3 -1 1 212864 models.common.RepNCSPELAN4 [128, 256, 128, 64, 1]
4 -1 1 590336 models.common.Conv [256, 256, 3, 2]
5 -1 1 847616 models.common.RepNCSPELAN4 [256, 512, 256, 128, 1]
6 -1 1 2360320 models.common.Conv [512, 512, 3, 2]
7 -1 1 2857472 models.common.RepNCSPELAN4 [512, 512, 512, 256, 1]
8 -1 1 2360320 models.common.Conv [512, 512, 3, 2]
9 -1 1 2857472 models.common.RepNCSPELAN4 [512, 512, 512, 256, 1]
10 -1 1 656896 models.common.SPPELAN [512, 512, 256]
11 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
12 [-1, 7] 1 0 models.common.Concat [1]
13 -1 1 3119616 models.common.RepNCSPELAN4 [1024, 512, 512, 256, 1]
14 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
15 [-1, 5] 1 0 models.common.Concat [1]
16 -1 1 912640 models.common.RepNCSPELAN4 [1024, 256, 256, 128, 1]
17 -1 1 590336 models.common.Conv [256, 256, 3, 2]
18 [-1, 13] 1 0 models.common.Concat [1]
19 -1 1 2988544 models.common.RepNCSPELAN4 [768, 512, 512, 256, 1]
20 -1 1 2360320 models.common.Conv [512, 512, 3, 2]
21 [-1, 10] 1 0 models.common.Concat [1]
22 -1 1 3119616 models.common.RepNCSPELAN4 [1024, 512, 512, 256, 1]
23 5 1 131328 models.common.CBLinear [512, [256]]
24 7 1 393984 models.common.CBLinear [512, [256, 512]]
25 9 1 656640 models.common.CBLinear [512, [256, 512, 512]]
26 0 1 1856 models.common.Conv [3, 64, 3, 2]
27 -1 1 73984 models.common.Conv [64, 128, 3, 2]
28 -1 1 212864 models.common.RepNCSPELAN4 [128, 256, 128, 64, 1]
29 -1 1 590336 models.common.Conv [256, 256, 3, 2]
30 [23, 24, 25, -1] 1 0 models.common.CBFuse [[0, 0, 0]]
31 -1 1 847616 models.common.RepNCSPELAN4 [256, 512, 256, 128, 1]
32 -1 1 2360320 models.common.Conv [512, 512, 3, 2]
33 [24, 25, -1] 1 0 models.common.CBFuse [[1, 1]]
34 -1 1 2857472 models.common.RepNCSPELAN4 [512, 512, 512, 256, 1]
35 -1 1 2360320 models.common.Conv [512, 512, 3, 2]
36 [25, -1] 1 0 models.common.CBFuse [[2]]
37 -1 1 2857472 models.common.RepNCSPELAN4 [512, 512, 512, 256, 1]
38[31, 34, 37, 16, 19, 22] 1 21547442 models.yolo.DualDDetect [3, [512, 512, 512, 256, 512, 512]] yolov9 summary: 930 layers, 60801842 parameters, 60801810 gradients, 266.1 GFLOPs

Transferred 438/1412 items from /content/yolov9-e.pt AMP: checks passed ✅ optimizer: SGD(lr=0.01) with parameter groups 230 weight(decay=0.0), 247 weight(decay=0.0005), 245 bias albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8)) train: Scanning /content/Data/Train/Images.cache... 0 images, 18 backgrounds, 0 corrupt: 100% 18/18 [00:00<?, ?it/s] Traceback (most recent call last): File "/content/yolov9/train.py", line 634, in main(opt) File "/content/yolov9/train.py", line 528, in main train(opt.hyp, opt, device, callbacks) File "/content/yolov9/train.py", line 177, in train train_loader, dataset = create_dataloader(train_path, File "/content/yolov9/utils/dataloaders.py", line 120, in create_dataloader dataset = LoadImagesAndLabels( File "/content/yolov9/utils/dataloaders.py", line 498, in init assert nf > 0 or not augment, f'{prefix}No labels found in {cache_path}, can not start training. {HELP_URL}' AssertionError: train: No labels found in /content/Data/Train/Images.cache, can not start training. See https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data

Thanks in advance