GithubHelp home page GithubHelp logo

Comments (11)

cloudrivers avatar cloudrivers commented on July 25, 2024

Hi~
I have disabled builder.fp16_mode = True, then the onnx can be converted to trt. but when i execute trt_yolov3.py, meet below errors:

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/michael/tensorrt_demos/utils/yolov3.py", line 473, in detect
in zip(trt_outputs, self.output_shapes)]
File "/home/michael/tensorrt_demos/utils/yolov3.py", line 472, in
trt_outputs = [output.reshape(shape) for output, shape
ValueError: cannot reshape array of size 3042 into shape (1,255,13,13)

from tensorrt_demos.

jkjung-avt avatar jkjung-avt commented on July 25, 2024

Please refer to: http://disq.us/p/26kit21

It looks like your custom YOLOv3 model is only detecting 1 class of object. So you should modify "category_num" to 1, and 255 in "output_shapes" to 18.

p.s. (1 + 5) * 3 = 18

from tensorrt_demos.

cloudrivers avatar cloudrivers commented on July 25, 2024

Hi Jung, Thank you for the quick reply. you are correct. after change output_shapes to 18, it works. However i meet another issue as below. can you help on this?

demos$ python3 trt_yolov3.py --model yolov3-416 --image --filename 002.jpg
[array([-inf, -inf, -inf, ..., -inf, -inf, -inf], dtype=float32), array([nan, nan, nan, ..., nan, nan, nan], dtype=float32), array([nan, nan, nan, ..., nan, nan, nan], dtype=float32)]
/home/michael/tensorrt_demos/utils/yolov3.py:261: RuntimeWarning: invalid value encountered in greater_equal
pos = np.where(box_class_scores >= conf_th)
[array([-inf, -inf, -inf, ..., -inf, -inf, -inf], dtype=float32), array([nan, nan, nan, ..., nan, nan, nan], dtype=float32), array([nan, nan, nan, ..., nan, nan, nan], dtype=float32)]
[array([-inf, -inf, -inf, ..., -inf, -inf, -inf], dtype=float32), array([nan, nan, nan, ..., nan, nan, nan], dtype=float32), array([nan, nan, nan, ..., nan, nan, nan], dtype=float32)]
[array([-inf, -inf, -inf, ..., -inf, -inf, -inf], dtype=float32), array([nan, nan, nan, ..., nan, nan, nan], dtype=float32), array([nan, nan, nan, ..., nan, nan, nan], dtype=float32)]

from tensorrt_demos.

jkjung-avt avatar jkjung-avt commented on July 25, 2024

Have you tested your model with darknet first? Does it produce the correct result?

It appears that the optimized TensorRT engine outputs -inf (infinite) and nan (not a number -> out of float32 range) with 002.jpg as the input image.

from tensorrt_demos.

cloudrivers avatar cloudrivers commented on July 25, 2024

the model is trained with pytorch and it can be used to inference with pytorch env. but have not check with darknet

from tensorrt_demos.

jkjung-avt avatar jkjung-avt commented on July 25, 2024

So how did you convert the pytorch model to onnx? Were you able to verify the conversion is correct?

from tensorrt_demos.

cloudrivers avatar cloudrivers commented on July 25, 2024

ohh, I just use the code in your repo. yolov3_to_onnx.py and onnx_to_tensorrt.py.

from tensorrt_demos.

cloudrivers avatar cloudrivers commented on July 25, 2024

transfer model can't be used with this repo?

from tensorrt_demos.

jkjung-avt avatar jkjung-avt commented on July 25, 2024
  1. "yolov3_to_onnx.py" can only handle darknet models (.cfg & .weights files). In other words, it cannot handle pytorch models. (You said your model was trained with pytorch?)
  2. If you train a custom YOLOv3 model with darknet, you should be able to use most of the code in this repository. I think you'd only need to modify "category_num", "output_shapes" and "output_tensor_dims" as I've listed in the Disqus post: http://disq.us/p/26kit21

from tensorrt_demos.

cloudrivers avatar cloudrivers commented on July 25, 2024

Hi Jung,Thank you so much for the kindly explainition. darknet model works well with your repo.

from tensorrt_demos.

jkjung-avt avatar jkjung-avt commented on July 25, 2024

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.

from tensorrt_demos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.