首页 Paddle框架 帖子详情
cascade_rcnn_r50_fpn_1x_coco模型在预测时有时报错
收藏
快速回复
Paddle框架 问答模型训练 169 4
cascade_rcnn_r50_fpn_1x_coco模型在预测时有时报错
收藏
快速回复
Paddle框架 问答模型训练 169 4

通过PaddleDetection调用训练好的cascade_rcnn_r50_fpn_1x_coco模型,验证的时候发现大部分的图片都是可以正常检测的,偶尔会有报错的情况,检测所用的图片都是相同的环境下拍出来的,没有存在差异,真是奇怪!

0
收藏
回复
全部评论(4)
李长安
#2 回复于2021-08-12

偶尔报错的话我觉得差不多是图像读取问题,或者是图像有损坏的,写个脚本测一下吧

0
回复
叫我光光哥哥丶
#3 回复于2021-08-12
偶尔报错的话我觉得差不多是图像读取问题,或者是图像有损坏的,写个脚本测一下吧

我用stream读取图像是成功的,应该是没有损坏。看报错提示的是需要的参数与传递的参数不一致导致的,现在一头雾水,找不到问题点...

报错提示如下:

Traceback (most recent call last):
File "D:\PaddleDetection\deploy\python\infer.py", line 623, in
main()
File "D:\PaddleDetection\deploy\python\infer.py", line 590, in main
predict_image(detector, img_list, FLAGS.batch_size)
File "D:\PaddleDetection\deploy\python\infer.py", line 502, in predict_image
results = detector.predict(batch_image_list, FLAGS.threshold)
File "D:\PaddleDetection\deploy\python\infer.py", line 151, in predict
self.predictor.run()
RuntimeError: In user code:

File "D:\PaddleDetection\tools\export_model.py", line 108, in
main()
File "D:\PaddleDetection\tools\export_model.py", line 104, in main
run(FLAGS, cfg)
File "D:\PaddleDetection\tools\export_model.py", line 72, in run
trainer.export(FLAGS.output_dir)
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\ppdet\engine\trainer.py", line 507, in export
input_spec, static_model.forward.main_program,
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 534, in main_program
concrete_program = self.concrete_program
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 454, in concrete_program
return self.concrete_program_specify_input_spec(input_spec=None)
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 487, in concrete_program_specify_input_spec
concrete_program, _ = self.get_concrete_program(
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 402, in get_concrete_program
concrete_program, partial_program_layer = self._program_cache[cache_key]
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 711, in __getitem__
self._caches[item] = self._build_once(item)
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 698, in _build_once
concrete_program = ConcreteProgram.from_func_spec(
File "", line 2, in from_func_spec

File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\wrapped_decorator.py", line 25, in __impl__
return wrapped_func(*args, **kwargs)
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\dygraph\base.py", line 40, in __impl__
return func(*args, **kwargs)
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\program_translator.py", line 652, in from_func_spec
outputs = static_func(*inputs)
File "C:\Users\HUAOPT\AppData\Local\Temp\tmpkmolxce2.py", line 26, in forward
out = paddle.jit.dy2static.convert_ifelse(self.training, true_fn_1,
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\convert_operators.py", line 210, in convert_ifelse
return _run_py_ifelse(pred, true_fn, false_fn, true_args, false_args)
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\convert_operators.py", line 235, in _run_py_ifelse
return true_fn(*true_args) if pred else false_fn(*false_args)
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\ppdet\modeling\architectures\meta_arch.py", line 29, in forward
out = self.get_pred()
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\ppdet\modeling\architectures\cascade_rcnn.py", line 136, in get_pred
bbox_pred, bbox_num, mask_pred = self._forward()
File "C:\Users\HUAOPT\AppData\Local\Temp\tmpwh1cqohe.py", line 112, in _forward
__return_value_0, rois, rois_num = paddle.jit.dy2static.convert_ifelse(self
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\convert_operators.py", line 210, in convert_ifelse
return _run_py_ifelse(pred, true_fn, false_fn, true_args, false_args)
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\dygraph\dygraph_to_static\convert_operators.py", line 235, in _run_py_ifelse
return true_fn(*true_args) if pred else false_fn(*false_args)
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\ppdet\modeling\architectures\cascade_rcnn.py", line 114, in _forward
bbox_pred = self.bbox_post_process.get_pred(bbox, bbox_num,
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\ppdet\modeling\post_process.py", line 120, in get_pred
scaled_bbox = pred_bbox / scale_factor_list
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\layers\math_op_patch.py", line 300, in __impl__
current_block(self).append_op(
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\framework.py", line 2899, in append_op
op = Operator(
File "C:\Users\HUAOPT\AppData\Local\Programs\Python\Python39\lib\site-packages\paddle\fluid\framework.py", line 1977, in __init__
for frame in traceback.extract_stack():

PreconditionNotMetError: The Tensor's element number must be equal or greater than zero. The Tensor's shape is [-1, 4] now
[Hint: Expected numel() >= 0, but received numel():-4 < 0:0.] (at C:\home\workspace\Paddle_release4\paddle\fluid\framework\tensor.cc:59)
[operator < elementwise_div > error]

0
回复
绿
绿水音音
#4 回复于2021-08-13

训练cascade_rcnn的时候,遇到过同样的问题,至今未解决,求解
[07/20 22:29:52] ppdet.utils.checkpoint INFO: Save checkpoint: output/cascade_rcnn_r50_vd_fpn_ssld_2x_coco
[07/20 22:29:52] ppdet.engine INFO: Eval iter: 0
[07/20 22:30:01] ppdet.engine INFO: Eval iter: 100
[07/20 22:30:09] ppdet.engine INFO: Eval iter: 200
[07/20 22:30:16] ppdet.engine INFO: Eval iter: 300
[07/20 22:30:24] ppdet.engine INFO: Eval iter: 400
[07/20 22:30:31] ppdet.engine INFO: Eval iter: 500
[07/20 22:30:39] ppdet.engine INFO: Eval iter: 600
Traceback (most recent call last):
  File "tools/train.py", line 140, in 
    main()
  File "tools/train.py", line 136, in main
    run(FLAGS, cfg)
  File "tools/train.py", line 111, in run
    trainer.train(FLAGS.eval)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ppdet/engine/trainer.py", line 350, in train
    self._eval_with_loader(self._eval_loader)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ppdet/engine/trainer.py", line 366, in _eval_with_loader
    outs = self.model(data)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py", line 898, in __call__
    outputs = self.forward(*inputs, **kwargs)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ppdet/modeling/architectures/meta_arch.py", line 29, in forward
    out = self.get_pred()
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ppdet/modeling/architectures/cascade_rcnn.py", line 136, in get_pred
    bbox_pred, bbox_num, mask_pred = self._forward()
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ppdet/modeling/architectures/cascade_rcnn.py", line 115, in _forward
    im_shape, scale_factor)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ppdet/modeling/post_process.py", line 120, in get_pred
    scaled_bbox = pred_bbox / scale_factor_list
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/math_op_patch.py", line 250, in __impl__
    return math_op(self, other_var, 'axis', axis)
RuntimeError: (PreconditionNotMet) The Tensor's element number must be equal or greater than zero. The Tensor's shape is [-1, 4] now
  [Hint: Expected numel() >= 0, but received numel():-4 < 0:0.] (at /paddle/paddle/fluid/framework/tensor.cc:59)
  [operator < elementwise_div > error]

0
回复
叫我光光哥哥丶
#5 回复于2021-08-23

将分支切换到最新的release/2.2,即可解决

0
回复
需求/bug反馈?一键提issue告诉我们
发现bug?如果您知道修复办法,欢迎提pr直接参与建设飞桨~
在@后输入用户全名并按空格结束,可艾特全站任一用户