当我执行训练代码,出现了和别人一样的问题。
2023-07-21 19:13:14.701 | INFO | yolox.core.trainer:save_ckpt:318 - Save weights to ./YOLOX_outputs/yolox_s
2023-07-21 19:13:29.211 | INFO | yolox.core.trainer:after_train:183 - Training of experiment is done and the best AP is 0.00
2023-07-21 19:13:29.212 | ERROR | yolox.core.launch:_distributed_worker:147 - An error has been caught in function '_distributed_worker', process 'SpawnProcess-1' (332490), thread 'MainThread' (140111912740672):
and
........
AssertionError: Caught AssertionError in DataLoader worker process 0.
.........
assert img is not None
AssertionError
该错误的具体表现在:当跑完第10个epoch时,开始验证,然而验证失败。
查看其他人的issue,有提到是由于路径造成的,但是没有明确的解决方案。实际上这是你验证集缺失的图片造成的。如果你的coco数据集路径是正确的,那么检查文件(图片)是否存在。
你可以在cocodataset类中加一个函数,该类在yolox/data/datasets/coco.py文件中,你可以和我一样做。
def showpath(self, index):
file_name = self.annotations[index][3]
img_file = os.path.join(self.data_dir, self.name, file_name)
if not os.path.exists(img_file):
print(img_file)
然后你需要调用这个函数,来获得丢失的图片。
from yolox.data.datasets.coco import COCODataset
if __name__ == '__main__':
data_dir = "/home/jiangw/vocdetection/YOLOX-0.2.0/datasets/COCO"
valdataset = COCODataset(
data_dir=data_dir,
json_file='instances_val2017.json',
name="val2017",
img_size=(640, 640),
)
for i in range(valdataset.__len__()):
valdataset.showpath(i)
#img = valdataset.load_image(i)
然后你可以在这些图片的名字的前面加上
‘http://images.cocodataset.org/val2017/’
来下载丢失的图片。
如图