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

ValueError: setting an array element with a sequence. YOLOv10推理問題 #132

Open
yeh111w opened this issue Jun 24, 2024 · 3 comments
Open

Comments

@yeh111w
Copy link

yeh111w commented Jun 24, 2024

(yolov10) PS D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python> python trt.py -e yolov10n.trt  -i src/test.png -o yolov10-1.jpg
Namespace(engine='yolov10n.trt', image='src/test.png', output='yolov10-1.jpg', video=None, end2end=False)
643.9112716024184 FPS
Traceback (most recent call last):
  File "D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python\trt.py", line 31, in <module>
    origin_img = pred.inference(img_path, conf=0.1, end2end=args.end2end)
  File "D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python\utils\utils.py", line 143, in inference
    predictions = np.reshape(data, (1, -1, int(5+self.n_classes)))[0]
  File "C:\Users\admin\anaconda3\envs\yolov10\lib\site-packages\numpy\core\fromnumeric.py", line 285, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)
  File "C:\Users\admin\anaconda3\envs\yolov10\lib\site-packages\numpy\core\fromnumeric.py", line 56, in _wrapfunc
    return _wrapit(obj, method, *args, **kwds)
  File "C:\Users\admin\anaconda3\envs\yolov10\lib\site-packages\numpy\core\fromnumeric.py", line 45, in _wrapit
    result = getattr(asarray(obj), method)(*args, **kwds)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (4,) + inhomogeneous part.

用export.py導出後執行推理的報錯 不知是哪裡出現錯誤
感謝相助

@Linaom1214
Copy link
Owner

(yolov10) PS D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python> python trt.py -e yolov10n.trt  -i src/test.png -o yolov10-1.jpg
Namespace(engine='yolov10n.trt', image='src/test.png', output='yolov10-1.jpg', video=None, end2end=False)
643.9112716024184 FPS
Traceback (most recent call last):
  File "D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python\trt.py", line 31, in <module>
    origin_img = pred.inference(img_path, conf=0.1, end2end=args.end2end)
  File "D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python\utils\utils.py", line 143, in inference
    predictions = np.reshape(data, (1, -1, int(5+self.n_classes)))[0]
  File "C:\Users\admin\anaconda3\envs\yolov10\lib\site-packages\numpy\core\fromnumeric.py", line 285, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)
  File "C:\Users\admin\anaconda3\envs\yolov10\lib\site-packages\numpy\core\fromnumeric.py", line 56, in _wrapfunc
    return _wrapit(obj, method, *args, **kwds)
  File "C:\Users\admin\anaconda3\envs\yolov10\lib\site-packages\numpy\core\fromnumeric.py", line 45, in _wrapit
    result = getattr(asarray(obj), method)(*args, **kwds)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (4,) + inhomogeneous part.

用export.py導出後執行推理的報錯 不知是哪裡出現錯誤 感謝相助
ython trt.py -e yolov10n.trt -i src/test.png -o yolov10-1.jpg --end2end

@yeh111w
Copy link
Author

yeh111w commented Jun 25, 2024

我在utils.py新增了一條print(data)發現偵測的結果好像有問題 我使用的確實是yolov10的模型 也事先測試過才用export.py導出

(yolov10) PS D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python> python trt.py -e yolov10n.trt -i src/test.png -o yolov10-1.jpg --end2end
Namespace(engine='yolov10n.trt', image='src/test.png', output='yolov10-1.jpg', video=None, end2end=True)
600.8943711820675 FPS
[array([[[195.38824  , 221.79056  , 292.1822   , 529.76227  ],
        [197.53484  , 298.35803  , 295.02707  , 530.32666  ],
        [346.6612   , 405.95734  , 635.21063  , 639.4853   ],
        ...,
        [194.95767  ,   0.7081528, 419.5535   , 170.20163  ],
        [139.81746  , 605.20105  , 292.5382   , 638.29205  ],
        [194.95767  ,   0.7081528, 419.5535   , 170.20163  ]]],
      dtype=float32), array([300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300., 300., 300., 300., 300., 300., 300., 300., 300.,
       300., 300., 300.], dtype=float32), array([[9.51683879e-01, 1.13234375e-04, 6.40200669e-05, 5.96735190e-05,
        4.98595800e-05, 3.48081230e-05, 3.29557297e-05, 3.19418214e-05,
        2.24740907e-05, 2.21256687e-05, 2.06234217e-05, 1.98333673e-05,
        1.86317466e-05, 1.83428929e-05, 1.80585193e-05, 1.70974781e-05,
        1.67014205e-05, 1.65714537e-05, 1.60616109e-05, 1.59366191e-05,
        1.48545796e-05, 1.38460045e-05, 1.36313456e-05, 1.32119585e-05,
        1.28054744e-05, 1.25088409e-05, 1.20296390e-05, 1.18431381e-05,
        1.09531238e-05, 1.08678860e-05, 1.03702132e-05, 1.00511597e-05,
        9.97294137e-06, 9.81832636e-06, 9.36871675e-06, 9.22346953e-06,
        9.15169312e-06, 9.00981013e-06, 8.87012720e-06, 8.87012720e-06,
        8.73260979e-06, 8.53032088e-06, 8.46393777e-06, 8.39807217e-06,
        8.26787345e-06, 8.13969200e-06, 8.13969200e-06, 8.07634933e-06,
        8.01349961e-06, 8.01349961e-06, 8.01349961e-06, 7.76695197e-06,
        7.52799042e-06, 7.29637895e-06, 7.18326055e-06, 7.18326055e-06,
        7.18326055e-06, 7.07189520e-06, 6.74805187e-06, 6.59173429e-06,
        6.38892925e-06, 6.09636027e-06, 6.04891829e-06, 5.90879608e-06,
        5.77191986e-06, 5.55080214e-06, 5.33815546e-06, 5.25539599e-06,
        5.25539599e-06, 5.13365512e-06, 5.05406570e-06, 5.01473460e-06,
        4.93698917e-06, 4.86044837e-06, 4.86044837e-06, 4.78509446e-06,
        4.71090880e-06, 4.71090880e-06, 4.63787319e-06, 4.63787319e-06,
        4.56597036e-06, 4.56597036e-06, 4.56597036e-06, 4.42549026e-06,
        4.35687980e-06, 4.25595363e-06, 4.18997115e-06, 4.15736440e-06,
        4.09291124e-06, 4.09291124e-06, 4.06105983e-06, 3.90548394e-06,
        3.84493524e-06, 3.58387456e-06, 3.55598468e-06, 3.55598468e-06,
        3.47361083e-06, 3.47361083e-06, 3.44657883e-06, 3.39314465e-06,
        3.36673952e-06, 3.34053925e-06, 3.34053925e-06, 3.28874921e-06,
        3.28874921e-06, 3.28874921e-06, 3.28874921e-06, 3.23776203e-06,
        3.23776203e-06, 3.18756520e-06, 3.13814689e-06, 3.13814689e-06,
        3.08949461e-06, 3.08949461e-06, 3.04159630e-06, 3.04159630e-06,
        2.99444082e-06, 2.99444082e-06, 2.92507502e-06, 2.90231196e-06,
        2.87972603e-06, 2.85731585e-06, 2.85731585e-06, 2.85731585e-06,
        2.85731585e-06, 2.72647026e-06, 2.68420035e-06, 2.68420035e-06,
        2.66331176e-06, 2.66331176e-06, 2.66331176e-06, 2.64258574e-06,
        2.62202116e-06, 2.62202116e-06, 2.46316108e-06, 2.46316108e-06,
        2.44399280e-06, 2.40610234e-06, 2.36879919e-06, 2.36879919e-06,
        2.36879919e-06, 2.36879919e-06, 2.29591910e-06, 2.29591910e-06,
        2.29591910e-06, 2.22528115e-06, 2.22528115e-06, 2.22528115e-06,
        2.19078152e-06, 2.19078152e-06, 2.19078152e-06, 2.15681666e-06,
        2.12337841e-06, 2.10685425e-06, 2.04203320e-06, 2.02614206e-06,
        2.02614206e-06, 2.02614206e-06, 1.97920667e-06, 1.96380438e-06,
        1.94852191e-06, 1.93335836e-06, 1.93335836e-06, 1.93335836e-06,
        1.91831305e-06, 1.88857234e-06, 1.88857234e-06, 1.87387536e-06,
        1.85929287e-06, 1.84482360e-06, 1.84482360e-06, 1.81622238e-06,
        1.78806454e-06, 1.78806454e-06, 1.77414961e-06, 1.74664399e-06,
        1.73305170e-06, 1.73305170e-06, 1.67973144e-06, 1.65368954e-06,
        1.62805168e-06, 1.62805168e-06, 1.62805168e-06, 1.60281104e-06,
        1.60281104e-06, 1.59033777e-06, 1.59033777e-06, 1.56568194e-06,
        1.56568194e-06, 1.54140844e-06, 1.52941300e-06, 1.52941300e-06,
        1.50570168e-06, 1.50570168e-06, 1.47082221e-06, 1.45937611e-06,
        1.43675061e-06, 1.43675061e-06, 1.43675061e-06, 1.41447595e-06,
        1.39254666e-06, 1.37095731e-06, 1.37095731e-06, 1.34970253e-06,
        1.32877733e-06, 1.32877733e-06, 1.32877733e-06, 1.32877733e-06,
        1.31843660e-06, 1.28789520e-06, 1.28789520e-06, 1.28789520e-06,
        1.26792827e-06, 1.26792827e-06, 1.26792827e-06, 1.25806127e-06,
        1.23855682e-06, 1.23855682e-06, 1.22891822e-06, 1.22891822e-06,
        1.21935489e-06, 1.20986567e-06, 1.20986567e-06, 1.20986567e-06,
        1.20986567e-06, 1.20045047e-06, 1.19110848e-06, 1.19110848e-06,
        1.19110848e-06, 1.17264210e-06, 1.17264210e-06, 1.17264210e-06,
        1.16351657e-06, 1.16351657e-06, 1.15446210e-06, 1.15446210e-06,
        1.15446210e-06, 1.14547788e-06, 1.14547788e-06, 1.13656370e-06,
        1.12771886e-06, 1.11894303e-06, 1.11894303e-06, 1.11023530e-06,
        1.10159544e-06, 1.10159544e-06, 1.10159544e-06, 1.09302266e-06,
        1.08451673e-06, 1.08451673e-06, 1.08451673e-06, 1.06770278e-06,
        1.06770278e-06, 1.05939398e-06, 1.05114964e-06, 1.04296964e-06,
        1.03485320e-06, 1.03485320e-06, 1.03485320e-06, 1.02679996e-06,
        1.01880926e-06, 1.01880926e-06, 1.01880926e-06, 1.01880926e-06,
        1.01088085e-06, 1.01088085e-06, 1.01088085e-06, 9.95208552e-07,
        9.87463750e-07, 9.87463750e-07, 9.79779429e-07, 9.72154680e-07,
        9.72154680e-07, 9.72154680e-07, 9.64589276e-07, 9.57082875e-07,
        9.57082875e-07, 9.57082875e-07, 9.49634682e-07, 9.42244640e-07,
        9.42244640e-07, 9.42244640e-07, 9.34912009e-07, 9.27636449e-07,
        9.27636449e-07, 9.20417563e-07, 9.20417563e-07, 9.13254837e-07,
        9.13254837e-07, 9.06147761e-07, 8.99096108e-07, 8.99096108e-07,
        8.99096108e-07, 8.85156965e-07, 8.78268565e-07, 8.71433883e-07,
        8.71433883e-07, 8.64652293e-07, 8.64652293e-07, 8.57923567e-07]],
      dtype=float32), array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
        0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
        0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
        0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
        0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
        0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
        0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
        0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
        0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
        0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
        0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,
        0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
        0., 0., 0., 0., 0., 0., 0., 2., 2., 0., 0., 0., 1., 0., 0., 0.,
        0., 1., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1., 0., 0.,
        0., 0., 1., 0., 1., 0., 0., 0., 2., 0., 2., 0., 0., 0., 0., 0.,
        0., 2., 0., 0., 1., 0., 0., 0., 2., 0., 0., 2., 0., 0., 0., 1.,
        0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 2., 0., 0., 0., 1.,
        0., 0., 0., 0., 0., 0., 0., 1., 1., 0., 1., 0., 0., 0., 0., 0.,
        0., 0., 2., 0., 0., 0., 2., 0., 0., 2., 0., 1.]], dtype=float32)]
Traceback (most recent call last):
  File "D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python\trt.py", line 31, in <module>
    origin_img = pred.inference(img_path, conf=0.1, end2end=args.end2end)
  File "D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python\utils\utils.py", line 138, in inference
    final_boxes -= dwdh
ValueError: operands could not be broadcast together with shapes (300,) (4,) (300,)

@yeh111w
Copy link
Author

yeh111w commented Jun 26, 2024

(yolov10) PS D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python> python trt.py -e yolov10n.trt  -i src/test.png -o yolov10-1.jpg
Namespace(engine='yolov10n.trt', image='src/test.png', output='yolov10-1.jpg', video=None, end2end=False)
643.9112716024184 FPS
Traceback (most recent call last):
  File "D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python\trt.py", line 31, in <module>
    origin_img = pred.inference(img_path, conf=0.1, end2end=args.end2end)
  File "D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python\utils\utils.py", line 143, in inference
    predictions = np.reshape(data, (1, -1, int(5+self.n_classes)))[0]
  File "C:\Users\admin\anaconda3\envs\yolov10\lib\site-packages\numpy\core\fromnumeric.py", line 285, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)
  File "C:\Users\admin\anaconda3\envs\yolov10\lib\site-packages\numpy\core\fromnumeric.py", line 56, in _wrapfunc
    return _wrapit(obj, method, *args, **kwds)
  File "C:\Users\admin\anaconda3\envs\yolov10\lib\site-packages\numpy\core\fromnumeric.py", line 45, in _wrapit
    result = getattr(asarray(obj), method)(*args, **kwds)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (4,) + inhomogeneous part.

用export.py導出後執行推理的報錯 不知是哪裡出現錯誤 感謝相助
ython trt.py -e yolov10n.trt -i src/test.png -o yolov10-1.jpg --end2end
D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python> python trt.py -e yolov10n.trt -i src/test.png -o yolov10-1.jpg --end2end
Traceback (most recent call last):
File "D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python\trt.py", line 31, in
origin_img = pred.inference(img_path, conf=0.1, end2end=args.end2end)
File "D:\python test\yolov10\TensorRT-For-YOLO-Series-cuda-python\utils\utils.py", line 138, in inference
final_boxes -= dwdh
ValueError: operands could not be broadcast together with shapes (300,) (4,) (300,)
這是模型出問題嗎?

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

2 participants