JdeRobot / ObjectDetector

16 stars 14 forks source link

Device agnostic version of the detector #45

Closed jmvega closed 4 years ago

jmvega commented 4 years ago

Following the setup instructions, all dependencies are satistied, but using Pip3 to install them, in order to ease compatibility with PyQt5. The configuration file "objectdetector.yml" is set to "Local".

The problem is when the software is executed. The command to do that is: python3 objectdetector.py objectdetector.yml. But different dynamic libraries are not satisfied:

The following message "If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly." seems to say I necessarily need Nvidia.

So, the question is: do I necessarily need an Nvidia GPU to execute the code?

naxvm commented 4 years ago

Hi Julio,

Theoretically there is no dependence on a GPU in order to the code to run. However, you might need to modify the file Net/TensorFlow/network.py file at this point, leaving it as follows:

        '''
        gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.8)
        config = tf.ConfigProto(gpu_options=gpu_options,
                                log_device_placement=False)
        '''
        self.sess = tf.Session(graph=detection_graph)

This might do it, as it is the only connection between the code and a GPU. Please let me know if it works in order to modify the source code. Notice as well that this project is prepared to work on ROS Kinetic (Python 2.7). However, my current Master Thesis works on ROS Melodic + Python 3.6, so maybe we can update the implementation of this object detector in order to work on that environment.

jmvega commented 4 years ago

Thank you, @naxvm. I did that change, but It still showing the same error.

naxvm commented 4 years ago

Could you share your traceback?

jmvega commented 4 years ago

For sure. I attached below: 2020-02-27 09:59:55.345353: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory 2020-02-27 09:59:55.345478: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or directory 2020-02-27 09:59:55.345495: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.

naxvm commented 4 years ago

Maybe you installed tensorflow-gpu instead of tensorflow for another purpose. It seems to look for TensorRT libraries, which you should not have unless you have a NVIDIA GPU installed in your system.

Please, check this with:

pip3 uninstall tensorflow-gpu
pip3 uninstall tensorflow
pip3 install tensorflow

Maybe this removes the TensorRT bindings.

jmvega commented 4 years ago

1.- When I try to uninstall tf-gpu is says: WARNING: Skipping tensorflow-gpu as it is not installed.

2.- Then, I uninstall tf: Found existing installation: tensorflow 2.1.0 Uninstalling tensorflow-2.1.0: Would remove: /usr/local/bin/estimator_ckpt_converter /usr/local/bin/saved_model_cli /usr/local/bin/tensorboard /usr/local/bin/tf_upgrade_v2 /usr/local/bin/tflite_convert /usr/local/bin/toco /usr/local/bin/toco_from_protos /usr/local/lib/python3.5/dist-packages/tensorflow-2.1.0.dist-info/* /usr/local/lib/python3.5/dist-packages/tensorflow/* /usr/local/lib/python3.5/dist-packages/tensorflow_core/* Proceed (y/n)? y Successfully uninstalled tensorflow-2.1.0

3.- And then, I install tf again and it says: Successfully installed tensorflow-2.1.0

4.- Trying to execute "object-detector" again and it still showing the same error.

naxvm commented 4 years ago

This was designed on TensorFlow 1.x, maybe the issue is located at that point. You can try pip3 install tensorflow==1.14

jmvega commented 4 years ago

I did it. I uninstall tf2.1 and install tf1.14. It says: Successfully installed tensorboard-1.14.0 tensorflow-1.14.0 tensorflow-estimator-1.14.0

And yes, the problem is dissapeared!! But there is a new problem, a file is missing: Net/TensorFlow/ssdlite_mobilenet_v2_coco_2018_05_29.pb

Traceback (most recent call last): File "objectdetector.py", line 100, in <module> network = DetectionNetwork(net_prop) File "/object-detector/Net/TensorFlow/network.py", line 33, in __init__ serialized_graph = fid.read() File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/lib/io/file_io.py", line 122, in read self._preread_check() File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/lib/io/file_io.py", line 84, in _preread_check compat.as_bytes(self.__name), 1024 * 512) tensorflow.python.framework.errors_impl.NotFoundError: Net/TensorFlow/ssdlite_mobilenet_v2_coco_2018_05_29.pb; No such file or directory

I went into that folder and I unzip a "model" zipped file, but the unzipped filename was different, so I changed to this one and it worked (I could have changed the model in the configuration file as well), but a new problem appeared: Traceback (most recent call last): File "objectdetector.py", line 100, in <module> network = DetectionNetwork(net_prop) File "/object-detector/Net/TensorFlow/network.py", line 43, in __init__ self.sess = tf.Session(graph=detection_graph, config=config) NameError: name 'config' is not defined

I guess the problem is the configuration file, which is showed below: `ObjectDetector: Source: Local # Local (local camera), Video (local file), Stream (ROS/ICE)

Local: DeviceNo: 0 # Device number for the desired webcam

Video: Path: "~/walking.mp4"

Stream: Server: ICE # "ROS", "ICE", "Deactivate" Proxy: "cameraA:tcp -h localhost -p 9999" Format: RGB8 Topic: "/usb_cam/image_raw" Name: cameraA

Network: Framework: TensorFlow # Currently supported: "Keras" or "TensorFlow"

Model: VGG_512_512_coco.h5

Model: ssdlite_mobilenet_v2_coco_2018_05_29.pb
Dataset: COCO # available: VOC, COCO, KITTI, OID, PET

NodeName: dl-objectdetector`

Any suggestions?

naxvm commented 4 years ago

Great to know that Julio!

With respect to the .pb filename, the way you did it is valid as well, thanks for the notice.

This new error is related to the correction I indicated you on here. You have to change as well this line

self.sess = tf.Session(graph=detection_graph, config=config)

into this one:

self.sess = tf.Session(graph=detection_graph)

I hope it works now.

jmvega commented 4 years ago

Yeah! Now it's working! Thank you very much for your help, @naxvm.

naxvm commented 4 years ago

Fine! Happy detections :grinning:

jmplaza commented 4 years ago

The changes in the code to solve it have not been merged in the repository. Please @jmvega submit a pull-request and check it before merging it

naxvm commented 4 years ago

Fixed on #56