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

trt_outputs = [output.reshape(shape) for output, shape ValueError: cannot reshape array of size 20577 into shape (1,255,19,19) #55

Closed
chenyuqing opened this issue Feb 11, 2020 · 4 comments

Comments

@chenyuqing
Copy link

(base) tim@tim-System-Product-Name:~/workspace/tensorrt_demos$ python trt_yolov3.py --model yolov3-608 --usb --vid 0
[TensorRT] INFO: Glob Size is 128825344 bytes.
[TensorRT] INFO: Added linear block of size 47316992
[TensorRT] INFO: Added linear block of size 23658496
[TensorRT] INFO: Added linear block of size 11829248
[TensorRT] INFO: Added linear block of size 2957312
[TensorRT] INFO: Added linear block of size 1478656
[TensorRT] INFO: Added linear block of size 739328
[TensorRT] INFO: Found Creator ResizeNearest
[TensorRT] INFO: Found Creator ResizeNearest
[TensorRT] INFO: Deserialize required 1140534 microseconds.
Traceback (most recent call last):
File "trt_yolov3.py", line 96, in
main()
File "trt_yolov3.py", line 88, in main
loop_and_detect(cam, trt_yolov3, conf_th=0.3, vis=vis)
File "trt_yolov3.py", line 56, in loop_and_detect
boxes, confs, clss = trt_yolov3.detect(img, conf_th)
File "/home/tim/workspace/tensorrt_demos/utils/yolov3.py", line 473, in detect
in zip(trt_outputs, self.output_shapes)]
File "/home/tim/workspace/tensorrt_demos/utils/yolov3.py", line 472, in
trt_outputs = [output.reshape(shape) for output, shape
ValueError: cannot reshape array of size 20577 into shape (1,255,19,19)

@jkjung-avt
Copy link
Owner

jkjung-avt commented Feb 11, 2020

Please refer to this post: #51 (comment)

20577 / 19 / 19 = 57
(14 + 5) * 3 = 57

I think your custom YOLOv3 model is detecting 14 classes of objects. So you should modify "category_num" from 80 to 14, and "output_shapes" from 255 to 57.

@chenyuqing
Copy link
Author

It works, Thaks a lot ! ~ @jkjung-avt

@jkjung-avt
Copy link
Owner

You are welcome.

@jkjung-avt
Copy link
Owner

I've added a "--category_num" command-line option to make it easier to adapt my TensorRT YOLOv3 code to custom trained models. Please check out my blog post TensorRT YOLOv3 For Custom Trained Models for details.

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