PaddlePaddle / PaddleDetection

Object Detection toolkit based on PaddlePaddle. It supports object detection, instance segmentation, multiple object tracking and real-time multi-person keypoint detection.
Apache License 2.0
12.85k stars 2.9k forks source link

直接利用提供的CDLA数据的预训练测试报错:AttributeError: 'Tensor' object has no attribute 'keys' #8823

Closed codeman008 closed 6 months ago

codeman008 commented 9 months ago

问题确认 Search before asking

Bug组件 Bug Component

Deploy

Bug描述 Describe the Bug

下载CDLA数据的预训练及推理模型:(picodet_lcnet_x1_0_fgd_layout_cdla)https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.6/ppstructure/docs/models_list.md 运行指令:python3 tools/infer.py -c configs/picodet/legacy_model/application/layout_analysis/picodet_lcnet_x1_0_layout.yml --slim_config configs/picodet/legacy_model/application/layout_analysis/picodet_lcnet_x2_5_layout.yml -o weights='output/picodet_lcnet_x1_0_fgd_layout_cdla_infer/best_model.pdparams' --infer_dir='dataset/test_data/' --output_dir=output_dir_baidu_test/ --draw_threshold=0.5 修改picodet_lcnet_x1_0_layout.yml 相关配置可以成功测试自己下载CDLA训练之后的模型,但直接跑提供的picodet_lcnet_x1_0_fgd_layout_cdla 报错: image 请大佬帮忙解答一下谢谢

复现环境 Environment

环境没问题,能够跑train及train之后的测试

Bug描述确认 Bug description confirmation

是否愿意提交PR? Are you willing to submit a PR?

lyuwenyu commented 9 months ago

你先别加后面那一串参数 看下能跑通嘛

wjli-debug commented 9 months ago

我实际就是参考文档中的单卡训练:python main.py --validate -c pptsm_fight_frames_dense.yaml,没有加入其他参数;只是修改了yaml里面的数据集路径

wjli-debug commented 9 months ago

Bug描述 中我并没使用

lyuwenyu commented 9 months ago

另外你确定一下paddleocr文档里用的paddledet的版本 是不是能对上

wjli-debug commented 9 months ago

https://github.com/PaddlePaddle/PaddleDetection/blob/release/2.7/docs/advanced_tutorials/customization/action_recognotion/videobased_rec.md 我参考的这个md文档,但是显然这里没有给出paddleocr的版本

wjli-debug commented 9 months ago

在这个md文档里,我是参考打架的数据集更换成自定义数据集,均是进行裁剪、做标签和修改了yaml里面的数据集输入,这部分是成功的,只是后面报错: Traceback (most recent call last): File "main.py", line 141, in main() File "main.py", line 129, in main train_model(cfg, File "/data1/docker_project/PaddleVideo-develop/paddlevideo/tasks/train.py", line 238, in train_model outputs = model(data, mode='train') File "/data1/docker_project/ENV/pad/lib/python3.8/site-packages/paddle/nn/layer/layers.py", line 1429, in call return self.forward(*inputs, **kwargs) File "/data1/docker_project/PaddleVideo-develop/paddlevideo/modeling/framework/recognizers/base.py", line 49, in forward return self.train_step(data_batch) File "/data1/docker_project/PaddleVideo-develop/paddlevideo/modeling/framework/recognizers/recognizer2d.py", line 48, in train_step loss_metrics = self.head.loss(cls_score, labels) File "/data1/docker_project/PaddleVideo-develop/paddlevideo/modeling/heads/base.py", line 110, in loss top1a, top5a = self.get_acc(scores, labels_a, valid_mode) File "/data1/docker_project/PaddleVideo-develop/paddlevideo/modeling/heads/base.py", line 157, in get_acc top5 = paddle.metric.accuracy(input=scores, label=labels, k=5) File "/data1/docker_project/ENV/pad/lib/python3.8/site-packages/paddle/metric/metrics.py", line 805, in accuracy topk_out, topk_indices = paddle.topk(input, k=k) File "/data1/docker_project/ENV/pad/lib/python3.8/site-packages/paddle/tensor/search.py", line 1009, in topk out, indices = _C_ops.topk(x, k, axis, largest, sorted) ValueError: (InvalidArgument) x has only 2 element, can not find 5 top values. [Hint: Expected x.numel() >= k, but received x.numel():2 < k:5.] (at /paddle/paddle/phi/kernels/gpu/top_k_kernel.cu:84)

codeman008 commented 9 months ago

你先别加后面那一串参数 看下能跑通嘛
不传参直接跑跑不通了,我用自己训练的cdla模型测试是没问题的,但是下载提供的cdla预训练模型就报错,yml文件用的和训练cdla的是同一个

wjli-debug commented 9 months ago

直接运行python main.py不加参数?均使用默认?

LokeZhou commented 9 months ago

在这个md文档里,我是参考打架的数据集更换成自定义数据集,均是进行裁剪、做标签和修改了yaml里面的数据集输入,这部分是成功的,只是后面报错: Traceback (most recent call last): File "main.py", line 141, in main() File "main.py", line 129, in main train_model(cfg, File "/data1/docker_project/PaddleVideo-develop/paddlevideo/tasks/train.py", line 238, in train_model outputs = model(data, mode='train') File "/data1/docker_project/ENV/pad/lib/python3.8/site-packages/paddle/nn/layer/layers.py", line 1429, in call return self.forward(*inputs, **kwargs) File "/data1/docker_project/PaddleVideo-develop/paddlevideo/modeling/framework/recognizers/base.py", line 49, in forward return self.train_step(data_batch) File "/data1/docker_project/PaddleVideo-develop/paddlevideo/modeling/framework/recognizers/recognizer2d.py", line 48, in train_step loss_metrics = self.head.loss(cls_score, labels) File "/data1/docker_project/PaddleVideo-develop/paddlevideo/modeling/heads/base.py", line 110, in loss top1a, top5a = self.get_acc(scores, labels_a, valid_mode) File "/data1/docker_project/PaddleVideo-develop/paddlevideo/modeling/heads/base.py", line 157, in get_acc top5 = paddle.metric.accuracy(input=scores, label=labels, k=5) File "/data1/docker_project/ENV/pad/lib/python3.8/site-packages/paddle/metric/metrics.py", line 805, in accuracy topk_out, topk_indices = paddle.topk(input, k=k) File "/data1/docker_project/ENV/pad/lib/python3.8/site-packages/paddle/tensor/search.py", line 1009, in topk out, indices = _C_ops.topk(x, k, axis, largest, sorted) ValueError: (InvalidArgument) x has only 2 element, can not find 5 top values. [Hint: Expected x.numel() >= k, but received x.numel():2 < k:5.] (at /paddle/paddle/phi/kernels/gpu/top_k_kernel.cu:84)

先不做任何改动,直接运行文档说明看看能否运行