PaddlePaddle / PaddleHub

Awesome pre-trained models toolkit based on PaddlePaddle. (400+ models including Image, Text, Audio, Video and Cross-Modal with Easy Inference & Serving)【安全加固,暂停交互,请耐心等待】
https://www.paddlepaddle.org.cn/hub
Apache License 2.0
12.68k stars 2.08k forks source link

Paddle hub solov2 [operator < gather > error] #1691

Open JunhuaY opened 2 years ago

JunhuaY commented 2 years ago

欢迎您反馈PaddleHub使用问题,非常感谢您对PaddleHub的贡献! 在留下您的问题时,辛苦您同步提供如下信息:

PaddleHub 2.1.1 与 PaddlePaddle 2.2.0 安装在windows10 anaconda上时 运行solov2 示例程序

import cv2 import paddlehub as hub

img = cv2.imread('/PATH/TO/IMAGE') model = hub.Module(name='solov2', use_gpu=False) output = model.predict(image=img, visualization=False)

出现报错 W1111 19:56:47.858419 4732 analysis_predictor.cc:1353] Deprecated. Please use CreatePredictor instead. e[37m--- Fused 0 subgraphs into layer_norm op.e[0m e[37m--- fused 0 pairs of fc gru patternse[0m Traceback (most recent call last): File "tes.py", line 7, in output = model.predict(image=img, visualization=True) File "C:\Users\mushroom\anaconda3\envs\paddle_env\lib\site-packages\paddlehub\compat\paddle_utils.py", line 220, in runner return func(*args, **kwargs) File "C:\Users\mushroom.paddlehub\modules\solov2\module.py", line 150, in predict self.predictor.zero_copy_run() IndexError: In user code:

File "tools/export_model.py", line 89, in <module>
  main()
File "tools/export_model.py", line 63, in main
  test_fetches = model.test(feed_vars, exclude_nms=FLAGS.exclude_nms)
File "/paddle/tools/PaddleDetection/ppdet/modeling/architectures/solov2.py", line 175, in test
  return self.build(feed_vars, mode='test')
File "/paddle/tools/PaddleDetection/ppdet/modeling/architectures/solov2.py", line 110, in build
  return self.bbox_head.get_prediction(*seg_inputs)
File "/paddle/tools/PaddleDetection/ppdet/modeling/anchor_heads/solov2_head.py", line 336, in get_prediction
  im_info[idx])
File "/paddle/tools/PaddleDetection/ppdet/modeling/anchor_heads/solov2_head.py", line 382, in get_seg_single
  strides = fluid.layers.gather(strides, index=inds[:, 0])
File "/usr/local/lib/python3.7/site-packages/paddle/fluid/layers/nn.py", line 8328, in gather
  attrs={'overwrite': overwrite})
File "/usr/local/lib/python3.7/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op
  return self.main_program.current_block().append_op(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/paddle/fluid/framework.py", line 2917, in append_op
  attrs=kwargs.get("attrs", None))
File "/usr/local/lib/python3.7/site-packages/paddle/fluid/framework.py", line 2014, in __init__
  for frame in traceback.extract_stack():

OutOfRangeError: The element of Index must be less than the size of input dim size of axis which is 3872, but received index element which is 3872 in the 20 index.
  [Hint: Expected p_index[i] < input_size, but received p_index[i]:3872 >= input_size:3872.] (at C:\home\workspace\Paddle_release\paddle/fluid/operators/gather.h:82)
  [operator < gather > error]

尝试更换目标图片仍然同样报错,应该与图片本身无关

rainyfly commented 2 years ago

看报错好像是gather这个算子发生了运行时错误,p_index[I]本应 < input_size,现在 = input_size了

JunhuaY commented 2 years ago

但是奇怪的是上个星期一点问题没有 今天再去试就这样了 重装了环境和paddle都没用

haoyuying commented 2 years ago

您好,可以降低paddle版本到2.1尝试是否能正常使用。

JunhuaY commented 2 years ago

我已经尝试了包括2.1.3 和 2.0.0 的paddle, 2.0的hub 在内的各种组合 仍然有同样报错 但是两到三周前这个solov2完全正常,不知道是不是这两周有什么改动?

rainyfly commented 2 years ago

您好,我用Paddle2.2能够复现出你这个错误,但是我这里使用Paddle 2.1.1的版本运行这个模型是没有问题的,因目前Paddle版本升级造成的兼容性问题给您带来的不便感到抱歉。

JunhuaY commented 2 years ago

我在这里尝试安装了2.1.1 还是有这个错误 能具体讲一下怎么删除更高版本的paddle和回到2.1.1的方式吗

JunhuaY commented 2 years ago

以及对应paddlehub版本应该是多少?

rainyfly commented 2 years ago
image

可以根据使用的环境(pip, conda等)参考如下Paddle安装页面进行2.1.1版本的安装 https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html 以下是在该版本环境下的复现结果

image
TimmmYang commented 2 years ago

碰到了同样的问题,请问现在有解决方案吗?paddlehub=2.1.1,paddle=2.2.1

ljwmusclenlper commented 2 years ago

各种版本组合试了都不行,估计是更新代码然后bug了

rainyfly commented 2 years ago

你好,需要安装飞桨的框架paddlepaddle的版本为2.1