使用nanodet模型进行训练时,修改好配置文件和数据集后,进行训练时报错如下:
UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3190.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
Traceback (most recent call last):
File "tools/train.py", line 155, in <module>
main(args)
File "tools/train.py", line 150, in main
trainer.fit(task, train_dataloader, val_dataloader, ckpt_path=model_resume_path)
.........(此处省略一万字)........
RuntimeError: split_with_sizes expects split_sizes to sum exactly to 35 (input tensor's size at dimension -1), but got split_sizes=[4, 32]
经搜集查询之后发现时num_class的设置少修改了一处,因为我要增加检测的类别数,配置文件中需要修改两处,但我只修改了一处,就会报上面错误。然后将两处num_class改成一样,就可以正常训练了。
需要修改的两处分别为model->head和model->aux_head
注意:
如果训练的数据要更换类别数,除了配置文件中类别数需要修改外,部署推理代码中的类别数也要做相应的修改。否则推理准确度会有问题。