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

yolov7 trt.py推理报错 #15

Closed
mingwz opened this issue Jul 27, 2022 · 5 comments
Closed

yolov7 trt.py推理报错 #15

mingwz opened this issue Jul 27, 2022 · 5 comments

Comments

@mingwz
Copy link

mingwz commented Jul 27, 2022

报错信息:
/home/zmw/anaconda3/envs/yolov7/lib/python3.7/site-packages/numpy/core/_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
return array(a, dtype, copy=False, order=order)
Traceback (most recent call last):
File "/home/zmw/tensorrt-python/yolov7/trt.py", line 30, in
origin_img = pred.inference(img_path, conf=0.3)
File "/home/zmw/tensorrt-python/utils/utils.py", line 87, in inference
predictions = np.reshape(data, (1, -1, int(5+self.n_classes)))[0]
File "<array_function internals>", line 6, in reshape
File "/home/zmw/anaconda3/envs/yolov7/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 299, in reshape
return _wrapfunc(a, 'reshape', newshape, order=order)
File "/home/zmw/anaconda3/envs/yolov7/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 55, in _wrapfunc
return _wrapit(obj, method, *args, **kwds)
File "/home/zmw/anaconda3/envs/yolov7/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 44, in _wrapit
result = getattr(asarray(obj), method)(*args, **kwds)
ValueError: cannot reshape array of size 4 into shape (1,newaxis,85)

完全跟着指导走的,不知道这里要怎么修改代码

@Linaom1214
Copy link
Owner

报错信息: /home/zmw/anaconda3/envs/yolov7/lib/python3.7/site-packages/numpy/core/_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray return array(a, dtype, copy=False, order=order) Traceback (most recent call last): File "/home/zmw/tensorrt-python/yolov7/trt.py", line 30, in origin_img = pred.inference(img_path, conf=0.3) File "/home/zmw/tensorrt-python/utils/utils.py", line 87, in inference predictions = np.reshape(data, (1, -1, int(5+self.n_classes)))[0] File "<array_function internals>", line 6, in reshape File "/home/zmw/anaconda3/envs/yolov7/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 299, in reshape return _wrapfunc(a, 'reshape', newshape, order=order) File "/home/zmw/anaconda3/envs/yolov7/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 55, in _wrapfunc return _wrapit(obj, method, *args, **kwds) File "/home/zmw/anaconda3/envs/yolov7/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 44, in _wrapit result = getattr(asarray(obj), method)(*args, **kwds) ValueError: cannot reshape array of size 4 into shape (1,newaxis,85)

完全跟着指导走的,不知道这里要怎么修改代码

检查一下类别数对不对

@mingwz
Copy link
Author

mingwz commented Jul 27, 2022

ok,解决了

@hellosuer
Copy link

ok,解决了
您好,麻烦问一下您是怎么解决这个问题的

@Hieu9825
Copy link

Hieu9825 commented Aug 2, 2022

您好,请问您是怎么​​解决这个问题的,请给我一个解决方案

@mingwz
Copy link
Author

mingwz commented Aug 5, 2022

在yolov7里面把yolo.py的返回值改了,按照建议的那样。还有就是现在暂时不支持端到端检测,好像也会报这个错误

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

4 participants