NVIDIA / object-detection-tensorrt-example

Running object detection on a webcam feed using TensorRT on NVIDIA GPUs in Python.
211 stars 61 forks source link

Error on running detect_objects_webcam.py #9

Open Clapaciuci opened 5 years ago

Clapaciuci commented 5 years ago

Machine settings: Ubuntu 18.04.3 LTS, Nvidia Quadro RTX 6000/PCIe/SSE2, NVIDIA-SMI 430.26 Driver Version: 430.26 , CUDA Version: 10.2 ;

I managed to setup the environment using the _./setupenvironment.sh but when i try to run the inference on webcam using _./setupenvironment.sh this error occurs:

"SSD_Model/detect_objects_webcam.py", line 12, in import utils.inference as inference_utils # TRT/TF inference wrappers File "/mnt/SSD_Model/utils/inference.py", line 60, in import utils.engine as engine_utils # TRT Engine creation/save/load utils File "/mnt/SSD_Model/utils/engine.py", line 11, in from utils.model import ModelData File "/mnt/SSD_Model/utils/model.py", line 9, in import graphsurgeon as gs File "/usr/lib/python3.5/dist-packages/graphsurgeon/init.py", line 9, in from graphsurgeon.StaticGraph import * File "/usr/lib/python3.5/dist-packages/graphsurgeon/StaticGraph.py", line 7, in from graphsurgeon._utils import _regex_list_contains_string, _generate_iterable_for_search, _clean_input_name File "/usr/lib/python3.5/dist-packages/graphsurgeon/_utils.py", line 2, in from tensorflow import NodeDef ImportError: cannot import name 'NodeDef'

zarar7576 commented 5 years ago

It's probably because of a tensorflow version issue because python is trying to import NodeDef and can't find it:

"from tensorflow import NodeDef ImportError: cannot import name 'NodeDef'"

Which version of TensorFlow are you using?

If you are on 2.0 then try downgrading to 1.14.0 or else try upgrading to 1.14.0 I tried it in TesorFlow version 1.14.0 and 1.12.2 and it worked

cassini12 commented 4 years ago

Anyone get this working? I am at the same exact spot.. same error

cassini@cassini51:~$ python --version Python 2.7.15+ cassini@cassini51:~$ python3 --version Python 3.6.8

cassini@cassini51:~$ pip3 list |grep tensorflow DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning. tensorflow (1.15.0) tensorflow-estimator (1.13.0) tensorflow-gpu (1.14.0)

zarar7576 commented 4 years ago

What TensorFlow version are you using in docker? I had to install TensorFlow 1.14.0 for it to run

pip install tensorflow==1.14.0 pip install tensorflow-gpu==1.14.0

cassini12 commented 4 years ago

Just ran both of those commands, I honestly am not sure. I am new to all this. Was trying to follow along with the medium article just to familiarize myself with it. At first my issue was the setup_env but Now I feel I got that squared away and I am facing the NoDef issue

cassini12 commented 4 years ago

cassini@cassini51:~/Object-Detection/object-detection-tensorrt-example$ sudo ./setup_environment.sh Setting envivonment variables for the webcam non-network local connections being added to access control list VOCdevkit has already been downloaded Dockerfile has already been built Starting docker container

===================== == NVIDIA TensorRT ==

NVIDIA Release 19.05 (build 6392482)

NVIDIA TensorRT 5.1.5 (c) 2016-2019, NVIDIA CORPORATION. All rights reserved. Container image (c) 2019, NVIDIA CORPORATION. All rights reserved.

https://developer.nvidia.com/tensorrt

To install Python sample dependencies, run /opt/tensorrt/python/python_setup.sh

root@81666cad449d:/mnt# python SSD_Model/detect_objects_webcam.py Traceback (most recent call last): File "SSD_Model/detect_objects_webcam.py", line 12, in import utils.inference as inference_utils # TRT/TF inference wrappers File "/mnt/SSD_Model/utils/inference.py", line 60, in import utils.engine as engine_utils # TRT Engine creation/save/load utils File "/mnt/SSD_Model/utils/engine.py", line 11, in from utils.model import ModelData File "/mnt/SSD_Model/utils/model.py", line 9, in import graphsurgeon as gs File "/usr/lib/python3.5/dist-packages/graphsurgeon/init.py", line 9, in from graphsurgeon.StaticGraph import * File "/usr/lib/python3.5/dist-packages/graphsurgeon/StaticGraph.py", line 7, in from graphsurgeon._utils import _regex_list_contains_string, _generate_iterable_for_search, _clean_input_name File "/usr/lib/python3.5/dist-packages/graphsurgeon/_utils.py", line 2, in from tensorflow import NodeDef ImportError: cannot import name 'NodeDef' root@81666cad449d:/mnt#

zarar7576 commented 4 years ago

I had the same issue but after running

python_setup.sh

I downgraded the TensorFlow version inside the container by using pip

pip install tensorflow==1.14.0 pip install tensorflow-gpu==1.14.0

and it worked beautifully I even managed to use a version of Faster RCNN on this, I hope you resolve this issue TRT is a great tool

cassini12 commented 4 years ago

Update: pip install tensorflow==1.14.0 Running this worked! originally I only had done the GPU to 14 but it seems I needed both. Thank you

follow up, am I able to "modify" this object detection to include pictures of people/things I have? and train it to recognize distinctly?

zarar7576 commented 4 years ago

You can you will need to modify the OpenCV input code ill share something tomorrow that might help you It takes a bit of work but once you get it, it's pretty easy and you can modify it for any object you want

cassini12 commented 4 years ago

Awesome, I look forward to that! Thank you for all your help and support

cassini12 commented 4 years ago

If anyone knows, After running it once, I have to RM the .buf before it will run again. Is this normal? /mnt/SSD_Model/utils/../workspace/engines/FLOAT/engine_bs_1.buf