Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PaddleX推理程序报错:ValueError: (InvalidArgument) generate_proposals_v2(): argument 'Scores' (position 0) must be Tensor, but got Tensor (at ..\paddle\fluid\pybind\op_function_common.cc:818),直接load和predict不能用了 #1635

Open
dingjingru opened this issue Dec 1, 2022 · 17 comments
Assignees

Comments

@dingjingru
Copy link

Checklist:

  1. 查找历史相关issue寻求解答
  2. 翻阅FAQ常见问题汇总和答疑
  3. 确认bug是否在新版本里还未修复
  4. 翻阅PaddleX 使用文档

描述问题

复现

  1. 您是否已经正常运行我们提供的教程

  2. 您是否在教程的基础上修改代码内容?还请您提供运行的代码

  3. 您使用的数据集是?

  4. 请提供您出现的报错信息及相关log

环境

  1. 请提供您使用的PaddlePaddle和PaddleX的版本号

  2. 请提供您使用的操作系统信息,如Linux/Windows/MacOS

  3. 请问您使用的Python版本是?

  4. 请问您使用的CUDA/cuDNN的版本号是?

@dingjingru dingjingru changed the title PaddleX推理程序报错: PaddleX推理程序报错:ValueError: (InvalidArgument) generate_proposals_v2(): argument 'Scores' (position 0) must be Tensor, but got Tensor (at ..\paddle\fluid\pybind\op_function_common.cc:818),直接load和predict不能用了 Dec 1, 2022
@lailuboy
Copy link
Collaborator

lailuboy commented Dec 1, 2022

还请提供详细错误信息,还有版本信息,以及调用的具体模型和相关代码

@jc-zju
Copy link

jc-zju commented Dec 2, 2022

还请提供详细错误信息,还有版本信息,以及调用的具体模型和相关代码

我也是相同问题,用你们示例中给的安全帽检测代码没有改动(paddlex.det.YOLOv3),使用的自己的数据集
环境如下:
ubuntu20.04
python3.7
paddlepaddle-gpu2.4.0
paddlex2.1.0
cuda11.6
cuDNN8.4.0

报错信息如下:

(most recent call last):
File "/home/jjc/Software/anaconda3/envs/paddlex/lib/python3.7/code.py", line 90, in runcode
exec(code, self.locals)
File "", line 1, in
File "/home/jjc/Software/pycharm-community-2022.2.4/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/home/jjc/Software/pycharm-community-2022.2.4/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/jjc/Program/Helmet/train.py", line 76, in
use_vdl=False) # 其用visuadl进行可视化训练记录
File "/home/jjc/Software/anaconda3/envs/paddlex/lib/python3.7/site-packages/paddlex/cv/models/detector.py", line 334, in train
use_vdl=use_vdl)
File "/home/jjc/Software/anaconda3/envs/paddlex/lib/python3.7/site-packages/paddlex/cv/models/base.py", line 397, in train_loop
return_details=True)
File "/home/jjc/Software/anaconda3/envs/paddlex/lib/python3.7/site-packages/paddlex/cv/models/detector.py", line 499, in evaluate
outputs = self.run(self.net, data, 'eval')
File "/home/jjc/Software/anaconda3/envs/paddlex/lib/python3.7/site-packages/paddlex/cv/models/detector.py", line 105, in run
net_out = net(inputs)
File "/home/jjc/Software/anaconda3/envs/paddlex/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py", line 948, in call
return self.forward(*inputs, **kwargs)
File "/home/jjc/Software/anaconda3/envs/paddlex/lib/python3.7/site-packages/paddlex/ppdet/modeling/architectures/meta_arch.py", line 71, in forward
outs.append(self.get_pred())
File "/home/jjc/Software/anaconda3/envs/paddlex/lib/python3.7/site-packages/paddlex/ppdet/modeling/architectures/yolo.py", line 124, in get_pred
return self._forward()
File "/home/jjc/Software/anaconda3/envs/paddlex/lib/python3.7/site-packages/paddlex/ppdet/modeling/architectures/yolo.py", line 115, in _forward
self.inputs['im_shape'], self.inputs['scale_factor'])
File "/home/jjc/Software/anaconda3/envs/paddlex/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py", line 948, in call
return self.forward(*inputs, **kwargs)
File "/home/jjc/Software/anaconda3/envs/paddlex/lib/python3.7/site-packages/paddlex/ppdet/modeling/post_process.py", line 67, in forward
bboxes, score = self.decode(head_out, rois, im_shape, scale_factor)
File "/home/jjc/Software/anaconda3/envs/paddlex/lib/python3.7/site-packages/paddlex/ppdet/modeling/layers.py", line 548, in call
self.clip_bbox, self.scale_x_y)
File "/home/jjc/Software/anaconda3/envs/paddlex/lib/python3.7/site-packages/paddlex/ppdet/modeling/ops.py", line 703, in yolo_box
boxes, scores = core.ops.yolo_box(x, origin_shape, *attrs)
ValueError: (InvalidArgument) yolo_box(): argument 'X' (position 0) must be Tensor, but got Tensor (at /paddle/paddle/fluid/pybind/op_function_common.cc:818)

@sralvins
Copy link

sralvins commented Dec 8, 2022

我也遇到了这个问题。在aistudio里运行“基于时空信息的异常行为检测”没有报错,但在自己的服务器上报ValueError,报错信息正如这个issue。我看了下aistudio环境里的paddle是2.2.2版本(自己服务器安装的是2.4.0),尝试降级paddle,降到了2.3.2版本,就可以正常运行。应该是是paddle v2.4.0的bug吧。而且报错信息也太扯了:“... must be Tensor, but got Tensor ...”

@ulen2000
Copy link

我也遇到同样的问题。 今天刚解决,只要把paddle版本降低到2.3.2就可以了

@mochaoxiong
Copy link

我也遇到同样的问题。 今天刚解决,只要把paddle版本降低到2.3.2就可以了

你是对的。应该是版本问题。我改了也可以了。感谢

@linuxonly801
Copy link

我也是同样的问题,也是把paddle换成了2.3.2解决的。
只是觉得这个报错很搞笑:must be Tensor, but got Tensor。我当时还怀疑了一下自己的英语水平。。。

@Guo2Wa
Copy link

Guo2Wa commented Apr 5, 2023

太神了。上CSDN搜了半天找不到答案,上Gitvhub一秒解决了

@zingcz
Copy link

zingcz commented May 10, 2023

这个问题现在依旧存在,paddlepaddle回退2.3.2版本后解决

@2018-Summer
Copy link

果然也是这个问题。paddlepaddle-gpu 2.4.2.post117 退到 paddlepaddle-gpu 2.3.2.post116,就完美的解决了,真是很奔溃;感谢感谢

@code-leitianshuo
Copy link

对的,我也是这样,目前2.4.2都没被修复呢

@GitYesm
Copy link

GitYesm commented Jul 3, 2023

降倒2.3.2还是会错 X ValueError: (InvalidArgument) yolo_box(): argument 'X' (position 0) must be Tensor, but got Tensor (at /paddle/paddle/fluid/pybind/op_function_common.cc:818),应该怎么解决这个问题?

@2018-Summer
Copy link

你python是3.7的吗?要是不是最好把python版本换回来。

@code-leitianshuo
Copy link

code-leitianshuo commented Jul 9, 2023 via email

@Grubby-Wang
Copy link

paddle =2.4.0版本是遇到同样的问题,训练时正常没有报错,但是一个epco结束开始验证就报这个错误:
ValueError: (InvalidArgument) yolo_box(): argument 'X' (position 0) must be Tensor, but got Tensor

退回到2.3.2版本又提示:开始train时又提示:
AttributeError( --> 317 "module 'pyarrow' has no attribute '{0}'".format(name) 318 ) 319 AttributeError: module 'pyarrow' has no attribute 'default_serialization_context'

真的是崩溃!

@Grubby-Wang
Copy link

paddle =2.4.0版本是遇到同样的问题,训练时正常没有报错,但是一个epco结束开始验证就报这个错误: ValueError: (InvalidArgument) yolo_box(): argument 'X' (position 0) must be Tensor, but got Tensor

退回到2.3.2版本又提示:开始train时又提示: AttributeError( --> 317 "module 'pyarrow' has no attribute '{0}'".format(name) 318 ) 319 AttributeError: module 'pyarrow' has no attribute 'default_serialization_context'

真的是崩溃!

到底有没有解决办法!

@ThelilinNB
Copy link

降倒2.3.2还是会错 X ValueError: (InvalidArgument) yolo_box(): argument 'X' (position 0) must be Tensor, but got Tensor (at /paddle/paddle/fluid/pybind/op_function_common.cc:818),应该怎么解决这个问题?

你好 ,请问你解决了这个问题了么

@DreamMaker777
Copy link

接口改太多了,可以参照paddledetection的代码,在proposal_generator.py文件中将ops.generate_proposals相关的代码改为:
if hasattr(paddle.vision.ops, "generate_proposals"):
# print("in")
generate_proposals = getattr(paddle.vision.ops,
"generate_proposals")
else:
generate_proposals = ops.generate_proposals
# generate_proposals = ops.generate_proposals
# print("score:", scores.shape)
rpn_rois, rpn_rois_prob, rpn_rois_num = generate_proposals(
目前paddle-gpu2.6.0可用,你可能还会遇到dim的问题,同样参照paddledetection对应部分修改。但是推理时,我遇到了ValueError: (InvalidArgument) multiclass_nms3(): argument (position 4) must be double, but got str (at ..\paddle\fluid\pybind\op_function_common.cc:236)问题,暂时没有找到解决的方案。求助~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests