# TensorRT inference produces unexpected results

**URL:** <https://forums.developer.nvidia.com/t/tensorrt-inference-produces-unexpected-results/77893>\
**Category:** TensorRT\
**Created:** [July 11, 2019, 2:23pm UTC](https://forums.developer.nvidia.com/t/tensorrt-inference-produces-unexpected-results/77893 "2019-07-11T14:23:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahul.ravikumar](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@rahul.ravikumar](https://forums.developer.nvidia.com/u/rahul.ravikumar)\
**Post date:** [July 11, 2019, 2:23pm UTC](https://forums.developer.nvidia.com/t/tensorrt-inference-produces-unexpected-results/77893/1 "2019-07-11T14:23:03Z")

</div>

I am adding support for TensorRT models in an open source project called DonkeyCar which is a self-driving RC Car.

Here is the source code that freezes the model.

> <https://github.com/autorope/donkeycar/blob/main/scripts/freeze_model.py>

Here is the code that does the inference  
[https://github.com/autorope/donkeycar/blob/dev/donkeycar/parts/tensorrt.py](https://github.com/autorope/donkeycar/blob/dev/donkeycar/parts/tensorrt.py)

When testing the converted UFF model I see TensorRT perform well with some sets of input data. Here is an example where the model does well:

[Pasteboard - Uploaded Image](https://pasteboard.co/Inuz69S.png) [Good TensorRT results]

However sometimes it produces very unexpected results, while the original Keras based (.h5) that the UFF model is based on performs well.

[Pasteboard - Uploaded Image](https://pasteboard.co/InuAY8O.png) [Good fit based on Keras Model]  
[Pasteboard - Uploaded Image](https://pasteboard.co/InuBxXa.png) [Bad TensorRT UFF Model

The second graph shows that inference is quite poor. The converted model is based on the Keras model shown in the above graph.

I am using TF 1.13.1 (with TF-GPU)  
CUDA 10.0  
TensorRT 5.1 GA

* * *

Do you any thoughts on how I can fix this ?

---

<div class="post-metadata">

**Author:** ![rahul.ravikumar](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@rahul.ravikumar](https://forums.developer.nvidia.com/u/rahul.ravikumar)\
**Post date:** [July 11, 2019, 6:24pm UTC](https://forums.developer.nvidia.com/t/tensorrt-inference-produces-unexpected-results/77893/2 "2019-07-11T18:24:40Z")

</div>

Did not realize that this was a place for issues with the container.

x-post at [https://devtalk.nvidia.com/default/topic/1057157/tensorrt/tensorrt-inference-produces-unexpected-results/](https://devtalk.nvidia.com/default/topic/1057157/tensorrt/tensorrt-inference-produces-unexpected-results/)
