前言
最近在使用yolov3算法做目标检测实验,从GitHub上clone了项目,运行时出现了不少错误,查了一大堆资料,一个个的解决,真是愁苦了孩子,故在此分享初次使用yolov3容易出现的几个错误的解决办法。
错误1:文件目录正确但提示No such file or directary:
解决办法:1、要使用绝对路径;2、在dataset.py文件的img_path处,要保证读取图片的位置要和train.txt,val.txt文件中图片的位置相衔接,这样才能在训练数据时准确读取到图片,label_path处读取的是数据集图片转化后的.txt标签文件
img_path = 'F:/001/PyTorch-YOLOv3/PyTorch-YOLOv3/data/coco' + img_path
#print (img_path)
# Extract image as PyTorch tensor
img = transforms.ToTensor()(Image.open(img_path).convert('RGB'))
# Handle images with less than three channels
if len(img.shape) != 3:
img = img.unsqueeze(0)
img &#