intel-iot-devkit / safety-gear-detector-python

Observe workers as they pass in front of a camera to determine if they have adequate safety protection.
https://software.intel.com/content/www/us/en/develop/topics/iot/reference-implementations/safety-gear-detector.html
BSD 3-Clause "New" or "Revised" License
56 stars 39 forks source link

AttributeError: 'openvino.inference_engine.ie_api.IENetwork' object has no attribute 'layers' #6

Open TuHechiceroFavorito opened 3 years ago

TuHechiceroFavorito commented 3 years ago

Not any expert in the field, so I feel very lost.

I get this error when I try to run it on the CPU.

I followed the instructions and checked every step and I don't see where I made a mistake, if any. I have also reinstalled OpenVINO with no luck.

Here is the full output:

32/person-detection-retail-0013.xml -sm ../resources/worker-safety-mobilenet/FP32/worker_safety_mobilenet.xml
Application running in Async mode
/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import fnmatch, glob, traceback, errno, sys, atexit, locale, imp, stat
Traceback (most recent call last):
  File "./safety_gear_detector.py", line 464, in <module>
    main()
  File "./safety_gear_detector.py", line 272, in main
    infer_network.load_model(conf_modelLayers, targetDevice, 1, 1, 2, cpu_extension)
  File "/home/atmos/safety-gear-detector-python/application/inference.py", line 79, in load_model
    [l for l in self.net.layers.keys() if l not in supported_layers]
AttributeError: 'openvino.inference_engine.ie_api.IENetwork' object has no attribute 'layers'
KnightRan commented 2 years ago

Same with me here. Is it because it not compatible with latest Openvino?

premraot commented 2 years ago

will check the issue and update you..

tyagisax commented 2 years ago

Not any expert in the field, so I feel very lost.

I get this error when I try to run it on the CPU.

I followed the instructions and checked every step and I don't see where I made a mistake, if any. I have also reinstalled OpenVINO with no luck.

Here is the full output:

32/person-detection-retail-0013.xml -sm ../resources/worker-safety-mobilenet/FP32/worker_safety_mobilenet.xml
Application running in Async mode
/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import fnmatch, glob, traceback, errno, sys, atexit, locale, imp, stat
Traceback (most recent call last):
  File "./safety_gear_detector.py", line 464, in <module>
    main()
  File "./safety_gear_detector.py", line 272, in main
    infer_network.load_model(conf_modelLayers, targetDevice, 1, 1, 2, cpu_extension)
  File "/home/atmos/safety-gear-detector-python/application/inference.py", line 79, in load_model
    [l for l in self.net.layers.keys() if l not in supported_layers]
AttributeError: 'openvino.inference_engine.ie_api.IENetwork' object has no attribute 'layers'

Hi,

Thanks for raising this issue with us.

Since it has not been mentioned from which branch the application was cloned and executed, I assume the 'Master' branch has been employed which has brought up the issue.

The "Master" branch supports OpenVINO 2020 versions or older, so in order to run the application with OpenVINO 2021 versions, it is recommended to use the "OpenVINO_2021.1" branch for the same (it will support all OpenVINO 2021 versions). The corresponding link is specified below for reference:

https://github.com/intel-iot-devkit/safety-gear-detector-python/tree/OpenVINO_2021.1

Please do reach out to us in the same thread if you continue to come across this issue.

Regards, Sarthak T

KnightRan commented 2 years ago

Hi guys, I am working on this project and I would like to add some features like providing sound alerts whenever workers didn't wear helmets or vest. Moreover,I would like this system to save data after each time they checked in. May I know, where can I edit it inside? Thank you

tyagisax commented 2 years ago

Hi guys, I am working on this project and I would like to add some features like providing sound alerts whenever workers didn't wear helmets or vest. Moreover,I would like this system to save data after each time they checked in. May I know, where can I edit it inside? Thank you

Hi KnightRan,

For editing the code to customize the application functionality, the safety_gear_detector.py file (inside the application folder) can be used as a base upon which the project can be built upon.

The script has specific functions pertaining to detection of helmets and vests. In this, specific additions to send out sound alerts (like Beepy Python library module) alongside modifications to store and transmit data (using MQTT and InfluxDB for instance) can be made.

Regards, Sarthak T

KnightRan commented 2 years ago

I see, thanks for your help and info Sarthak. Best regard

KnightRan commented 2 years ago

Hi guys, may I know what software to use to train the model as i want to improve the helmet detection.Thank you. Best regard

tyagisax commented 2 years ago

Hi guys, may I know what software to use to train the model as i want to improve the helmet detection.Thank you. Best regard

Hi KnightRan,

The application makes use of a pre-trained model for detecting helmets (worker safety mobilenet) hence it would not be advisable to retrain the model to achieve better results.

One alternative could be to select a specific model (performing helmet, jacket and other safety detections) which provides the desired detection accuracy level and integrate that with OpenVINO for inferencing. OpenVINO provides an option for the user to optimize the model using the "Model Optimizer" functionality wherein they can convert the model specific files into a format that is compatible with the toolkit. Please do refer the below mentioned link showing the detailed steps to execute the same:

https://docs.openvino.ai/latest/openvino_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html

Once the steps mentioned in the above link are executed, the generated xml and bin files can be used with the application to carry out the detections.

Regards, Sarthak T

KnightRan commented 2 years ago

Hi Sarthak, May i know what model that I can used other than worker safety mobilenet to optimize with Model Optimizer as I have struggle to find it. Thank you and best regard.

Regards, Malvin

tyagisax commented 2 years ago

Hi Sarthak, May i know what model that I can used other than worker safety mobilenet to optimize with Model Optimizer as I have struggle to find it. Thank you and best regard.

Regards, Malvin

Hi Malvin,

Most deep learning models tasked with safety gear detection are created using certain pretrained models as a base and ultimately using user defined datasets to train them for specific use cases. Keeping this in mind, one solution might be to use one such popular pretrained model in the form of SSD-Mobilenet object detection models (generally based on TensorFlow or Pytorch) to train and create your own defined models using custom datasets. These models can then be deployed with the OpenVINO toolkit using the model optimizer. Please do refer to the below mentioned links for reference:

https://www.tensorflow.org/lite/examples/object_detection/overview https://docs.openvino.ai/latest/omz_models_model_mobilenet_v2.html

Regards, Sarthak T

KnightRan commented 2 years ago

Hi Sarthak, Good day to you , just want to inform that the system detect the helmet eventho i am not wearing it. Is it possible to modify the code especially at line 155 to 165 under safety gear.py? If have may i know what is the recommended HSV value? Thank you and best regard.

Capture

image

tyagisax commented 2 years ago

Hi,

The current HSV values in the application are intended to capture different shades of orange color (a color generally associated with safety helmets) though in some cases it may lead to false positives. One recommendation might be to adjust these HSV values according to your specific use case (pertaining to specific color of helmets to be detected) using online tools which aid you with these particular settings. Please find below the link of one such tool which might assist you with the same:

http://colorizer.org/

Regards, Sarthak T