Convert YOLOV3 to TF- UFF - tennsorRT on Jetson Xavier

I am trying to convert YOLOv3 model to UFF, to run on jetson Xavier using TensorRT, but I need support with the steps involved. Note that I have Jetpack 4.1 setup on Jetson Xavier that has TensorRT 5.0.3 on it.

Here is the steps that I performed so far:

  1. From the original network, I froze the model to get the .pb file. Done on the Xavier using the following command :
    python3 --input_model="./model_data/yolo.h5" --output_model="./yolov3.pb"

  2. Convert the .pb file to a UFF file using the command from TensorRT package. The resulting UFF file is still platform independent, so this step can also be done on Xavier:
    convert-to-uff --input-file yolov3.pb -O NMS -p
    When executing this command with NMS option the converted file is so small (around 450kb), however when running the command :
    convert-to-uff --input-file yolov3.pb -p
    the same size of file is obtained from the .pb file

  3. The last step should include building a TensorRT engine from the UFF file that I obtained. Based on my understanding, this step must be done on the Xavier itself, since the resulting serialized engine is platform specific. How to proceed at this stage?

below I am including the scripts that I am passing to uff converter to obtain the uff file: :

import graphsurgeon as gs
import tensorflow as tf

Input = gs.create_node(“Input”,
shape=[1, 3, 300, 300])
PriorBox = gs.create_plugin_node(name=“GridAnchor”, op=“GridAnchor_TRT”,
aspectRatios=[1.0, 2.0, 0.5, 3.0, 0.33],
featureMapShapes=[19, 10, 5, 3, 2, 1])
NMS = gs.create_plugin_node(name=“NMS”, op=“NMS_TRT”,
inputOrder=[0, 2, 1],
concat_priorbox = gs.create_node(name=“concat_priorbox”, op=“ConcatV2”, dtype=tf.float32, axis=2)
concat_box_loc = gs.create_plugin_node(“concat_box_loc”, op=“FlattenConcat_TRT”, dtype=tf.float32, axis=1, ignoreBatch=0)
concat_box_conf = gs.create_plugin_node(“concat_box_conf”, op=“FlattenConcat_TRT”, dtype=tf.float32, axis=1, ignoreBatch=0)

namespace_plugin_map = {
“MultipleGridAnchorGenerator”: PriorBox,
“Postprocessor”: NMS,
“Preprocessor”: Input,
“ToFloat”: Input,
“image_tensor”: Input,
“MultipleGridAnchorGenerator/Concatenate”: concat_priorbox,
“concat”: concat_box_loc,
“concat_1”: concat_box_conf

def preprocess(dynamic_graph):
# Now create a new graph by collapsing namespaces
# Remove the outputs, so we just have a single output node (NMS).
dynamic_graph.remove(dynamic_graph.graph_outputs, remove_exclusive_dependencies=False)

What are the minimum changes that I have to make in order to get YOLOv3 running on the Xavier?

I am also tyring to implement the deepstream implementation in a seperate project hoping to get similar results since they did almost the same conversion but the code is crashing when I try to build the nbgstiva-app source but this I will leave it for a different thread

could you please help?


It’s recommended to use trt-yolo-app of this tutorial since YOLO requires some plugin implementation.

Currently, TensorRT Python API is not available for Jetson yet.
This limitation will avoid you to run a plugin layer with python implementation.

Another alternative is to use TF-TRT.
You can check the tutorial here:
If the YOLO .pb file is able to run on TensorFlow, you can switch to use TF-TRT.

However, the simplest way should still be trt-yolo-app.


Hi AastaLL,

I know you are trying to answer me on the other thread about trt-yolo-app, however I am replying also here jut to align what I did so far with your responses, this is the error that I am getting now when executing the repo

nvidia@jetson:~deepstream-plugins$ trt-yolo-app --flagfile=/home/nvidia/Projects/deepstream-plugins/config/deepstream-app_yolo_config.txt
Using previously generated plan file located at sources/lib/models/yolov3-kFLOAT-batch1.engine
Loading TRT Engine...
ERROR: The engine plan file is incompatible with this version of TensorRT, expecting, please rebuild.
Loading Complete!
trt-yolo-app: yolo.cpp:100: Yolo::Yolo(uint): Assertion `m_Engine != nullptr' failed.
Aborted (core dumped)

I know that my jetson Xavier has 5.0.3 TensorRT version installed on it, but from where the build is coming, is it the original build provided by the repo and how can I change it?

However, I didn’t try to implement yet, but I will wait for your response first regarding the trt-yolo-app.

Thank you so much for your support.



Please check the original topic for the suggestion: