YoloX 训练报错解决:AssertionError: Caught AssertionError in DataLoader worker process 0.

How to solve the problem: AssertionError: Caught AssertionError in DataLoader worker process 0 · Issue #1695 · Megvii-BaseDetection/YOLOX · GitHub

当我执行训练代码,出现了和别人一样的问题。
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/

来下载丢失的图片。

如图

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值