5

I am trying to train a model using Yolo V5.

I have the issue of Data base not found.

I have a train, test and valid files that contain all the image and labels files.

I have tested the files on googlecolap and it dose work. However, on my local machine it shows the issue of Exception: Dataset not found.

  (Yolo_5) D:\\YOLO_V_5\Yolo_V5\yolov5>python train.py --img 416 --batch 8 --epochs 100 --data /data.yaml --cfg models/yolov5s.yaml --weights '' --name yolov5s_results  --cache
Using torch 1.7.0 CUDA:0 (GeForce GTX 1080, 8192MB)

Namespace(adam=False, batch_size=8, bucket='', cache_images=True, cfg='models/yolov5s.yaml', data='.\\data.yaml', device='', epochs=100, evolve=False, exist_ok=False, global_rank=-1, hyp='data/hyp.scratch.yaml', image_weights=False, img_size=[416, 416], local_rank=-1, log_imgs=16, multi_scale=False, name='yolov5s_results', noautoanchor=False, nosave=False, notest=False, project='runs/train', rect=False, resume=False, save_dir='runs\\train\\yolov5s_results55', single_cls=False, sync_bn=False, total_batch_size=8, weights="''", workers=16, 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, 'anchors': 3, '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}

WARNING: Dataset not found, nonexistent paths: ['D:\\me1eye\\Yolo_V5\\valid\\images']
Traceback (most recent call last):
  File "train.py", line 501, in <module>
    train(hyp, opt, device, tb_writer, wandb)
  File "train.py", line 78, in train
    check_dataset(data_dict)  # check
  File "D:\me1eye\YOLO_V_5\Yolo_V5\yolov5\utils\general.py", line 92, in check_dataset
    raise Exception('Dataset not found.')
Exception: Dataset not found.
Internal process exited

(Olive_Yolo_5) D:\me1eye\YOLO_V_5\Yolo_V5\yolov5>
Zag.D
  • 59
  • 1
  • 1
  • 4

3 Answers3

10

there is a much simpler solution. Just go into data.yaml wherever you saved it and change the relative paths to absolut - i.e. just write the whole path! e.g.

train: C:\hazlab\BCCD\train\images
val: C:\hazlab\BCCD\valid\images

nc: 3
names: ['Platelets', 'RBC', 'WBC']

job done - note, as you are in Windows, there is a known issue in the invocation of tain.py - do not use quotes on the file names in the CLI e.g.

!python train.py --img 416 --batch 16 --epochs 100 --data C:\hazlab\BCCD\data.yaml --cfg ./models/custom_yolov5s.yaml --weights '' --name yolov5s_results  --cache
Saeed Nasehi
  • 940
  • 1
  • 11
  • 27
Eli Kling
  • 101
  • 1
  • 4
2

Well! I have also encountered this problem and now I fix it.

All you have to do is to keep train, test, validation (these three folders containing images and labels), and yolov5 folder (that is cloned from GitHub) in the same directory. Also, another thing is that the 'data.yaml' file has to be inside the yolov5 folder.

Command to train the model would be like this:

!python train.py --img 416 --batch 16 --epochs 10 --data ./data.yaml --cfg ./models/yolov5m.yaml --weights '' --name yolov5m_results
Hack-R
  • 22,422
  • 14
  • 75
  • 131
rudra
  • 21
  • 3
  • More specifically, Yolo v5 will look for these files in the ROOT directory. This is defined all over the place, but by default, it's the directory where the Yolo python files reside. – Ketil Malde Oct 05 '22 at 22:40
  • It is not necessary to keep/store your data in the yolov5 folder or relative to the same root folder. The data.yaml file can take any relative or absolute path to your data. – Valentin_Ștefan Nov 19 '22 at 19:56
1

The issue is due to not found actual dataset path. I found same issue when i trained the Yolov5 model on custom dataset using google colab, I did the following to resolve this.

Make sure provide correct path of data.yaml of dataset. Make sure path of dataset in data.yaml should be be corrected. train, test, and valid key should contain path with respect to the main path of the dataset. Example data.yaml file given below.

path: /content/drive/MyDrive/car-detection-dataset
train: train/images
val: valid/images
test: test/images

nc: 1
names: ['car']