Trying to convert Mobilenet_v2 from Tensorflow to Tensor RT


I am trying to convert the Tensorflow Version of Mobilenet_v2 to a Tensor RT Version. I have been using the following Project ( ) to learn how to convert Tensorflow Models. My issue occurs when I am trying to convert the frozen graphs to plans

Command Line:
python scripts/
Traceback (most recent call last):
File “scripts/”, line 9, in
from model_meta_mob_2 import NETS, FROZEN_GRAPHS_DIR, CHECKPOINT_DIR, PLAN_DIR
File “/home/nvidia/tf_to_trt_image_classification/scripts/”, line 71, in
‘model’: mobilenet_v2_1p0_224,
NameError: name ‘mobilenet_v2_1p0_224’ is not defined

Where, is a modified Version of the given in the Project. The same applies to the file.
The only changes made to the file are that on line 6 I have ‘from model_meta_mob_2 Import Nets’ instead of ‘model_meta Import Nets’

The changes to file are that I added;
‘Import slim.nets.mobilenet_v2’
and added to following to the NETS section;

‘mobilenet_v2_1p0_224’: {
‘model’: mobilenet_v2_1p0_224,
‘arg_scope’: nets.mobilenet_v2.mobilenet_v2_arg_scope,
‘num_classes’: 1001,
‘input_name’: ‘input’,
‘input_width’: 224,
‘input_height’: 224,
‘input_channels’: 3,
‘output_names’: [‘MobilenetV2/Logits/SpatialSqueeze’],
‘checkpoint_filename’: CHECKPOINT_DIR +
‘frozen_graph_filename’: FROZEN_GRAPHS_DIR + ‘mobilenet_v2_1p0_224.pb’,
‘plan_filename’: PLAN_DIR + ‘mobilenet_v2_1p0_224.plan’,
‘preprocess_fn’: preprocess_inception,
‘postprocess_fn’: postprocess_inception,

Other bits of info:

I have downloaded the checkpoints for MobileNet_V2_1.0_224 from

I am trying to run this on a Jetson TX2, with the lastest Version of Jetpack 3.2 and I have tensorflow 1.5 installed.

Any help would be greatly appreciated


It’s recommended to following the instruction shown in the main page:

Suppose the required models can be downloaded with this command:

source scripts/

And be transferred into frozen graphs with this command:

python scripts/



Thanks for the quick reply.

The issue is that the mobilenet_v2 is not part of the require models given in the project.
The commands worked perfectly for all the models that they listed though. What I was trying to do was to edit some files, such that they would work for mobilenet_v2 (mobilenet_v2_1.0_224 in particular)

I think my real issue is that I don’t know where to define mobilenet_v2_1.0_224, I thought I could simply edit the file and that would be sufficient. Which doesn’t seem to be correct, but I am not sure what to do instead


Could you try to use mobilenet_v2_1.0_224 instead of mobilenet_v2_1p0_224?


Hi AastaLLL,

changing it to mobilenet_v2_1.0_224 doesnt make a difference and the frozen file is called mobilenet_v2_1p0_224. However I did try changing both to mobilenet_v2_1.0_224 but it didn’t work.

I have been working on the issues some more and I believe my mistake lies with
‘output_names’: [‘MobilenetV2/Logits/SpatialSqueeze’],
from the meta file. This is something I simply copied from the project and changed ‘MobilenetV1’ to ‘MobilenetV2’. The error is that it isnt defined, however I don’t know where to define it, or what ‘output_names’ is meant to represent.



You can find the output name information via TensorFlow.
Please import your model first and print out the model definition with graphdef.


Hi Aastall,

I have not been able to try this yet. I will post here if I get it to work.
Thank you for your advice!


Did you have success in importing Mobilenet V2 into TensorRT?