Using Jetson Inference DetectNet with a Custom Object Detection Model

Hi, I’ve been told to open a separate issue for this so here we go. I’m trying to use one of my previously created custom object detection models inside the detecnet_camera example since it utilizes tensorRT for an optimized performance. To do this, I suppose I need to convert my frozen_graph.pb to something with .uff extension? Research tells me that I can convert .pb file to .uff using a conversion script which requires the .pb file and its output node names. This is where I’m a bit confused and that’s why I’m opening this issue. My frozen graph was created using ssd_inception_v2_coco_2018_01_28 version of the model. I’m not sure what my output node names are. I hope that this is enough information for someone to help me out. I need a step by step explanation of how to complete this conversion so that I can run it with the detectnet examples. Or if there’s another way of using the .pb file with detectnet, that would be great too. Thanks so much!

Hi,

Since uff parser is deprecated soon, it’s more recommended to use tf2onnx or keras2onnx instead:

Once you got the onnx-based model, you can feed it directly into TensorRT.
Thanks.

Hi, thanks for the quick reply! I tried installing keras2onnx on my Nano but neither pip nor building from source worked. All attempts failed to install the library. I’m getting the following error. Can you spot the problem here? Thanks!

pip3 install -U git+https://github.com/onnx/keras-onnx
Defaulting to user installation because normal site-packages is not writeable
Collecting git+https://github.com/onnx/keras-onnx
Cloning GitHub - onnx/keras-onnx: Convert tf.keras/Keras models to ONNX to /tmp/pip-req-build-scklko94
Running command git clone -q GitHub - onnx/keras-onnx: Convert tf.keras/Keras models to ONNX /tmp/pip-req-build-scklko94
Requirement already satisfied, skipping upgrade: numpy in /usr/local/lib/python3.6/dist-packages (from keras2onnx==1.7.1) (1.17.4)
Requirement already satisfied, skipping upgrade: protobuf in /usr/local/lib/python3.6/dist-packages (from keras2onnx==1.7.1) (3.11.0)
Requirement already satisfied, skipping upgrade: requests in /usr/local/lib/python3.6/dist-packages (from keras2onnx==1.7.1) (2.22.0)
Collecting onnx
Using cached onnx-1.7.0.tar.gz (5.5 MB)
Installing build dependencies … error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 /usr/local/lib/python3.6/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-oej_f32u/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i Simple index – setuptools wheel protobuf
cwd: None
Complete output (39 lines):
Traceback (most recent call last):
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/usr/local/lib/python3.6/dist-packages/pip/main.py”, line 23, in
from pip._internal.cli.main import main as _main # isort:skip # noqa
File “/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/main.py”, line 5, in
import locale
File “/usr/lib/python3.6/locale.py”, line 16, in
import re
File “/usr/lib/python3.6/re.py”, line 142, in
class RegexFlag(enum.IntFlag):
AttributeError: module ‘enum’ has no attribute ‘IntFlag’
Error in sys.excepthook:
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/apport_python_hook.py”, line 53, in apport_excepthook
if not enabled():
File “/usr/lib/python3/dist-packages/apport_python_hook.py”, line 24, in enabled
import re
File “/usr/lib/python3.6/re.py”, line 142, in
class RegexFlag(enum.IntFlag):
AttributeError: module ‘enum’ has no attribute ‘IntFlag’

Original exception was:
Traceback (most recent call last):
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/usr/local/lib/python3.6/dist-packages/pip/main.py”, line 23, in
from pip._internal.cli.main import main as _main # isort:skip # noqa
File “/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/main.py”, line 5, in
import locale
File “/usr/lib/python3.6/locale.py”, line 16, in
import re
File “/usr/lib/python3.6/re.py”, line 142, in
class RegexFlag(enum.IntFlag):
AttributeError: module ‘enum’ has no attribute ‘IntFlag’

ERROR: Command errored out with exit status 1: /usr/bin/python3 /usr/local/lib/python3.6/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-oej_f32u/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i Simple index – setuptools wheel protobuf Check the logs for full command output.

Hi,

Please check if this suggestion helps:

Thanks.

Hi, uninstalling enum34 actually worked! Thanks a lot again!