Comments (11)
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.
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.
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.
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.
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.
So how did you convert the pytorch model to onnx? Were you able to verify the conversion is correct?
from tensorrt_demos.
ohh, I just use the code in your repo. yolov3_to_onnx.py and onnx_to_tensorrt.py.
from tensorrt_demos.
transfer model can't be used with this repo?
from tensorrt_demos.
- "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?)
- 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.
Hi Jung,Thank you so much for the kindly explainition. darknet model works well with your repo.
from tensorrt_demos.
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)
- Calib.table not created Deepstream
- Error when install install_pycuda.sh file HOT 2
- Any plan about SwinIR? HOT 1
- Batch Processed Image Inference HOT 2
- Failure to Build ONNX from Custom Yolo HOT 2
- Error when running on separate thread HOT 2
- wrong many bounding box and wrong predict untrained class id HOT 2
- error happening when sh ./install_pycuda.sh HOT 3
- Integration With AGX Orin HOT 4
- yolov3 onnx format with low opset, suitable for tensorrt 6.5 HOT 1
- Trouble with linker on yolo plugin x86 HOT 2
- Xavier onnx to TensorRT error HOT 1
- How to prevent tensorrt from fusing the final layers when trying to convert tiny yolov3 to int8? HOT 2
- No output when running my own yolov4
- Failed to build the TensorRT engine --int8
- How do I free up memory when I want to switch models
- Cudnn initialization error: I already installed Cudnn but Why?
- Is there any way to avoid using the reshape operation after inference?
- DRIVE AGX Orin
- Facing Issue with yolo to onnx conversion with pre-trained yolov3-tiny model.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tensorrt_demos.