Tianxiaomo / pytorch-YOLOv4

PyTorch ,ONNX and TensorRT implementation of YOLOv4
Apache License 2.0
4.48k stars 1.49k forks source link

自己的数据集训练 TypeError: expected str, bytes or os.PathLike object, not NoneType #374

Closed Fee532 closed 3 years ago

Fee532 commented 3 years ago

log file path:log/log_2021-01-29_21-41-55.txt 2021-01-29 21:41:55,228 train.py[line:611] INFO: Using device cuda convalution havn't activate linear convalution havn't activate linear convalution havn't activate linear 2021-01-29 21:41:56,968 train.py[line:327] INFO: Starting training: Epochs: 300 Batch size: 64 Subdivisions: 16 Learning rate: 0.001 Training size: 7231 Validation size: 803 Checkpoints: True Device: cuda Images size: 608 Optimizer: adam Dataset classes: 1 Train label path:data/train.txt Pretrained:

Epoch 1/300: 0%| | 0/7231 [00:00<?, ?img/s] Traceback (most recent call last): File "train.py", line 626, in device=device, ) File "train.py", line 370, in train for i, batch in enumerate(train_loader): File "/home/fee/.conda/envs/envhrank/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 345, in next data = self._next_data() File "/home/fee/.conda/envs/envhrank/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 385, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/home/fee/.conda/envs/envhrank/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/fee/.conda/envs/envhrank/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/fee/pytorch-YOLOv4/dataset.py", line 275, in getitem img_path = os.path.join(self.cfg.dataset_dir, img_path) File "/home/fee/.conda/envs/envhrank/lib/python3.6/posixpath.py", line 80, in join a = os.fspath(a) TypeError: expected str, bytes or os.PathLike object, not NoneType

Fee532 commented 3 years ago

因为我的训练集采用了绝对路径所以os.path.join(self.cfg.dataset_dir, img_path),dataset_dir为none,为dataset_dir=''就可以解决。或者注释调之一句也不影响