PaddleX icon indicating copy to clipboard operation
PaddleX copied to clipboard

det_res category_id = label_to_cat_id_map[int(num_id)] KeyError: 3

Open liming1010 opened this issue 1 year ago • 2 comments

数据集校验通过,

(D:\conda\env\paddlex) D:\pyproject\PaddleX>python main.py -c paddlex/configs/object_detection/PicoDet-S.yaml -o Global.mode=check_dataset -o Global.dataset_dir=C:/Users/67343/Desktop/Data/img/img/dataset
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
Check dataset passed !

在训练的时候出现错误

(D:\conda\env\paddlex) D:\pyproject\PaddleX>python main.py -c paddlex/configs/object_detection/PicoDet-S.yaml  -o Global.mode=train -o Global.device=cpu -o Global.dataset_dir=C:/Users/67343/Desktop/Data/img/img/dataset
['D:\\conda\\env\\paddlex\\python.exe', 'tools/train.py', '--eval', '--config', 'C:\\Users\\67343\\.paddlex\\tmpj7kps06o\\detmodel_PicoDet-S.yml', '--use_vdl', 'True', '--vdl_log_dir', 'D:\\pyproject\\PaddleX\\output']

Log path: D:\pyproject\PaddleX\output\train.log

loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
[10/17 16:53:17] ppdet.data.source.coco INFO: Load [4 samples valid, 0 samples invalid] in file C:\Users\67343\Desktop\Data\img\img\dataset\annotations/instance_train.json.
[10/17 16:53:18] ppdet.engine WARNING: Samples in dataset are less than batch_size, please set smaller batch_size in TrainReader.
[10/17 16:53:18] ppdet.utils.checkpoint INFO: ['last_conv.weight'] in pretrained weight is not used in the model, and its will not be loaded
[10/17 16:53:18] ppdet.utils.checkpoint INFO: The shape [1000] in pretrained weight fc.bias is unmatched with the shape [96] in model head.conv_feat.se.0.fc.bias. And the weight fc.bias will not be loaded
[10/17 16:53:18] ppdet.utils.checkpoint INFO: The shape [1280, 1000] in pretrained weight fc.weight is unmatched with the shape [96, 96, 1, 1] in model head.conv_feat.se.0.fc.weight. And the weight fc.weight will not be loaded
[10/17 16:53:18] ppdet.utils.checkpoint INFO: The shape [1000] in pretrained weight fc.bias is unmatched with the shape [96] in model head.conv_feat.se.1.fc.bias. And the weight fc.bias will not be loaded
[10/17 16:53:18] ppdet.utils.checkpoint INFO: The shape [1280, 1000] in pretrained weight fc.weight is unmatched with the shape [96, 96, 1, 1] in model head.conv_feat.se.1.fc.weight. And the weight fc.weight will not be loaded
[10/17 16:53:18] ppdet.utils.checkpoint INFO: The shape [1000] in pretrained weight fc.bias is unmatched with the shape [96] in model head.conv_feat.se.2.fc.bias. And the weight fc.bias will not be loaded
[10/17 16:53:18] ppdet.utils.checkpoint INFO: The shape [1280, 1000] in pretrained weight fc.weight is unmatched with the shape [96, 96, 1, 1] in model head.conv_feat.se.2.fc.weight. And the weight fc.weight will not be loaded
[10/17 16:53:18] ppdet.utils.checkpoint INFO: The shape [1000] in pretrained weight fc.bias is unmatched with the shape [96] in model head.conv_feat.se.3.fc.bias. And the weight fc.bias will not be loaded
[10/17 16:53:18] ppdet.utils.checkpoint INFO: The shape [1280, 1000] in pretrained weight fc.weight is unmatched with the shape [96, 96, 1, 1] in model head.conv_feat.se.3.fc.weight. And the weight fc.weight will not be loaded
[10/17 16:53:19] ppdet.utils.checkpoint INFO: Finish loading model weights: C:\Users\67343/.cache/paddle/weights\PPLCNet_x0_75_pretrained.pdparams
[10/17 16:53:19] ppdet.utils.checkpoint INFO: Save checkpoint: D:\pyproject\PaddleX\output\0
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
[10/17 16:53:19] ppdet.engine INFO: Export inference config file to D:\pyproject\PaddleX\output\0\inference\inference.yml
I1017 16:53:25.913123   380 program_interpreter.cc:243] New Executor is Running.
[10/17 16:53:25] ppdet.engine INFO: Export model and saved in D:\pyproject\PaddleX\output\0\inference
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
[10/17 16:53:25] ppdet.data.source.coco INFO: Load [1 samples valid, 0 samples invalid] in file C:\Users\67343\Desktop\Data\img\img\dataset\annotations/instance_val.json.
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
Traceback (most recent call last):
  File "D:\pyproject\PaddleX\paddlex\repo_manager\repos\PaddleDetection\tools\train.py", line 212, in <module>
    main()
  File "D:\pyproject\PaddleX\paddlex\repo_manager\repos\PaddleDetection\tools\train.py", line 208, in main
    run(FLAGS, cfg)
  File "D:\pyproject\PaddleX\paddlex\repo_manager\repos\PaddleDetection\tools\train.py", line 161, in run
    trainer.train(FLAGS.eval)
  File "D:\pyproject\PaddleX\paddlex\repo_manager\repos\PaddleDetection\ppdet\engine\trainer.py", line 690, in train
    self._eval_with_loader(self._eval_loader)
  File "D:\pyproject\PaddleX\paddlex\repo_manager\repos\PaddleDetection\ppdet\engine\trainer.py", line 727, in _eval_with_loader
    metric.update(data, outs)
  File "D:\pyproject\PaddleX\paddlex\repo_manager\repos\PaddleDetection\ppdet\metrics\metrics.py", line 118, in update
    infer_results = get_infer_results(
  File "D:\pyproject\PaddleX\paddlex\repo_manager\repos\PaddleDetection\ppdet\metrics\coco_utils.py", line 53, in get_infer_results
    infer_res['bbox'] = get_det_res(
  File "D:\pyproject\PaddleX\paddlex\repo_manager\repos\PaddleDetection\ppdet\metrics\json_results.py", line 36, in get_det_res
    category_id = label_to_cat_id_map[int(num_id)]
KeyError: 3
Traceback (most recent call last):
  File "D:\pyproject\PaddleX\paddlex\utils\result_saver.py", line 29, in wrap
    result = func(self, *args, **kwargs)
  File "D:\pyproject\PaddleX\paddlex\engine.py", line 40, in run
    self._model.train()
  File "D:\pyproject\PaddleX\paddlex\model.py", line 94, in train
    trainer.train()
  File "D:\pyproject\PaddleX\paddlex\modules\base\trainer.py", line 71, in train
    train_result = self.pdx_model.train(**train_args)
  File "D:\pyproject\PaddleX\paddlex\repo_apis\PaddleDetection_api\object_det\model.py", line 145, in train
    return self.runner.train(
  File "D:\pyproject\PaddleX\paddlex\repo_apis\PaddleDetection_api\object_det\runner.py", line 55, in train
    return self.run_cmd(
  File "D:\pyproject\PaddleX\paddlex\repo_apis\base\runner.py", line 355, in run_cmd
    raise CalledProcessError(
paddlex.utils.errors.others.CalledProcessError: Command ['D:\\conda\\env\\paddlex\\python.exe', 'tools/train.py', '--eval', '--config', 'C:\\Users\\67343\\.paddlex\\tmpj7kps06o\\detmodel_PicoDet-S.yml', '--use_vdl', 'True', '--vdl_log_dir', 'D:\\pyproject\\PaddleX\\output'] returned non-zero exit status 1.

版本paddlex3.0-beta1

liming1010 avatar Oct 17 '24 08:10 liming1010

您好。数据是否有通过数据校验呢?

Sunting78 avatar Oct 17 '24 11:10 Sunting78

您好。数据是否有通过数据校验呢?

有的,问题开始那就有校验结果

liming1010 avatar Oct 18 '24 01:10 liming1010

您好。数据是否有通过数据校验呢?

大佬,5天过去了,重装还是这个错误,数据集校验是通过的

liming1010 avatar Oct 21 '24 03:10 liming1010

paddlex/configs/object_detection/PicoDet-S.yaml 配置文件中Train.num_classes与自己的数据集是一致的吗

zhangyubo0722 avatar Oct 21 '24 12:10 zhangyubo0722

不一致的话需要修改为自己数据集的类别数

zhangyubo0722 avatar Oct 21 '24 12:10 zhangyubo0722

不一致的话需要修改为自己数据集的类别数

可以了,就是这个东西困扰了几天,感谢大佬

liming1010 avatar Oct 22 '24 01:10 liming1010