!python3 train.py --model_def config/yolov3-custom.cfg --data_config config/custom.data --pretrained_weights weights/darknet53.conv.74
Namespace(batch_size=8, checkpoint_interval=1, compute_map=False, data_config='config/custom.data', epochs=100, evaluation_interval=1, gradient_accumulations=2, img_size=416, model_def='config/yolov3-custom.cfg', multiscale_training=True, n_cpu=8, pretrained_weights='weights/darknet53.conv.74')
Traceback (most recent call last):
File "train.py", line 99, in <module>
for batch_i, (_, imgs, targets) in enumerate(dataloader):
File "/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 637, in __next__
return self._process_next_batch(batch)
File "/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 658, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
TypeError: Traceback (most recent call last):
File "/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 138, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 138, in <listcomp>
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/ubuntu/PyTorch-YOLOv3/utils/datasets.py", line 130, in __getitem__
img, targets = horisontal_flip(img, targets)
File "/home/ubuntu/PyTorch-YOLOv3/utils/augmentations.py", line 8, in horisontal_flip
targets[:, 2] = 1 - targets[:, 2]
TypeError: 'NoneType' object is not subscriptable
I am getting this error for all images in my dataset except for some. Is there a contraint on the type or size of images? Am i missing something?
I found the fix by changing
path.replace("images", "labels").replace(".png", ".txt").replace(".jpg", ".txt")
with
path.replace("images", "labels").replace(".png", ".txt").replace(".jpg", ".txt").replace(".JPG", ".txt")
in datasets.py line 65
hi I have the same error with you but when I try to use your way to fix it still not work
me too
I found the fix by changing
path.replace("images", "labels").replace(".png", ".txt").replace(".jpg", ".txt")
with
path.replace("images", "labels").replace(".png", ".txt").replace(".jpg", ".txt").replace(".JPG", ".txt")in datasets.py line 65
Thank you for this information and it solved my problem.
Most helpful comment
I found the fix by changing
path.replace("images", "labels").replace(".png", ".txt").replace(".jpg", ".txt")with
path.replace("images", "labels").replace(".png", ".txt").replace(".jpg", ".txt").replace(".JPG", ".txt")