-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Unable to run custom YOLOv5 with Raspberry PI and NCS2 #11458
Comments
Not that long ago, in the Ultralytics repo support for OpenVINO was added: ultralytics/yolov5#6057 "OpenVINO Export" (Dec 22, 2021) |
Yes, I have tried running using the detect.py provided by Ultralytics using the xml file and it works. But I would like to use it with an NCS2, do you have any suggestion as to implement the integration with this intel hardware? |
Can you use your NCS2/MyriadX successfully in your environment for other models - just checking whether everything is installed properly (like in Linux environments to install a specific UDEV-rule first). |
Yes, I have tried using the demos provided by OpenVino, and it works. But I'm wondering if its possible to make yolov5s detect.py be compatible with ncs2? or do I have to put the xml file in the openvino2021 folder and create another script to run object detection? |
@Averen19 I was able to export the yolov5s model using The following may help you write your script to run inference. |
@jgespino Did you run this code in the openvino 2021.4 folder? Did you change anything from the script? Would it be possible to give a step by step guide on how you did it? |
@jgespino This is the result I get when i'm trying to run inferencing. Do you know whats the error? |
@Averen19 Couple of thigs:
Please install OpenVINO 2022 Runtime using the offline or online installer to include the MYRIAD plugin. Steps to download/convert model and run demo:
|
@jgespino by using the export.py with --include openvino, I no longer need to use the model optimizer right, or do i only convert to onnx using export.py and use openvino's model optimizer to convert to ir format. What I have done is to install openvino_2022 and tried running yolov5s.xml directly with export.py. I put in the yolov5_demo_OV2021.3.py and the yolov5s.xml into the openvino file and get such a result: If I was meant to use the model optimzer from openvino, I can't seem to find it in the openvino2022. |
@Averen19 Correct, you need to use export.py to convert pt model to onnx. Then use the model optimizer to convert to IR and specify the three outputs as expected by this demo code. If you use the IR file generated by the export.py the outputs are different and you will need to write your own inference script. |
@jgespino to use the model optimizer, I would need to get the dev tools build right instead of run time? I tried both and can't seem to find the mo.py file in to do model optimizing. |
@jgespino I realized that it might not be a .py file and just input what you wrote and got the following: |
Hi, I managed to run the yolov5.xml already thank you very much. However, I am unable to run it with the MYRIAD. My assumptions when installing openvino it comes preinstalled with ncs2 dependencies. This is the results I get when trying to run with Myriad. Also, if I were to implement this on a raspberry pi 4 would I also need openvino 2022? As far as I have found, openvino2022 is not compatible with Rpi. |
@Averen19 Looks like we missed uploading the OpenVINO 2022.1 package for Raspbian OS. I have reached out to my peers for assistance. In the meantime, you can download OpenVINO 2021.4.2 package for Rasbian OS. Please note that you need to match the OpenVINO version that is used to convert the model to IR and the runtime package installed on your pi. You can also build OpenVINO from source If you want to use the latest 2022.1 release on Raspberry Pi. Let me know if you see the same error converting the model on 2021.4.2. |
@jgespino I have installed the 2021.4.2 for Raspbian and I have done the necessary installation for NCS2 dependencies but I get the following error. I have check on windows using the same codes and files it works. |
@Averen19 What is the output of lsusb? After running the install_NCS_udev_rules.sh did you logout or reboot the pi? Could you verify your NCS 2 has been configured correctly by following the build and run object detection sample instructions in the documentation? |
I have rebooted the rpi and still have the same issue. Ive tried the example but I'm stuck at this step: I can't seem to find where the path to model is. |
@Averen19 you have to download the model as described in step 3:
or you can download it directly:
|
@jgespino Ive tried to run the model and get such a problem. |
Have you downloaded a model, or copied from another machine?
|
@jgespino Hi, I have tested with the example using MYRIAD and it works, I managed to get the out_0.bmp, proving that the MYRIAD plugin does work. I retried again with my yolov5 model but I still get stuck with the same result. |
The YoloV5 model is much bigger than e.g. the "face-detection-adas-0001.xml", requiring likely more time to compile the OpenCL-kernels. |
Hmm, ok, it's not stuck at loading the model (where the OpenCL kernels would be compiled), but at the previous step, "Preparing inputs". |
Hi, I managed to get it to run thank you. However, there are still quite a few issues. I've tried with camera and it is able to detect albeit very laggy, but when I try with images it will show the following, where it says that it is able to run but no result is shown. Also I tried to run it without MYRIAD and it comes with the following error, is it unable to detect the cpu in the RPI, making it unable to run? |
hmm, not sure I understood your response... But your additional notes are confusing... because then you say it's not working? Sometimes simple test-applications don't handle termination not correctly... Sometimes when an application exists or get terminated the connection and libraries are not closed gracefully - and starting the application again will fail with initializing the MYRIADX device again. The simple applications usually don't have proper error-handling or shutdown-sequences. |
There are other OpenVINO samples, like "https://docs.openvino.ai/2021.4/openvino_inference_engine_ie_bridges_python_sample_object_detection_sample_ssd_README.html", supporting a "labels" file; the application is reading the file, putting the labels in an array/map at startup. And then, instead of printing the integer "0" like in your example, "#0 77.4 %", using the integer "0" as index (array) or as a key (map) to look-up the label instead. |
Ok, I will look into that, but for now, it still doesn't create this result window when running the code on RPI as this was captured from windows. |
@Averen19 Are you using a custom trained model of yolov5s or the pre-trained model? I just tested on a fresh Raspberry Pi using the pre-trained model and everything is working as expected. Here are the steps I took: Convert the model on my Windows system running OpenVINO 2021.4.2
On Raspberry Pi, installed OpenVINO 2021.4.2 and configured per documentation.
The python code should show up a pop up window showing the camera feed with detections. For the labels I used the coco dataset labels and seem to line up to the detections. |
@Averen19 Maybe a bug in the code because the following always returns -1 when passing an image. Try changing it to the following for testing purposes and you should see a window with the image. |
@jgespino yeah, I'm not sure as to why it doesn't show the inferencing result with images. I'm using the same code on Windows and it works well but when I transfer over to RPi, only the real time camera works but not for images. Do you have any inclination for where the problem lies? Is there any software dependencies that may lead to such error? I tied to comment out the section you mentioned but its still just stuck at preparing input. |
@Averen19 Is it possible for you to share your custom model and input image with me? Feel free to attach it here or share privately via email (email is on my profile). |
@jgespino Hello, I have sent you my custom files to your email address. |
@Averen19 Thank you for sharing your model. I was able to run and display the inference results (see attached screenshot) by quickly modifying a couple of lines in the yolov5_demo_OV2021.3.py. Please note, this was only done to check that your model was able to run on NCS 2. The changes will break some functionality of this code. Please consider writing your own code to meet your projects needs by referencing the shared demo. You can also find additional information in the OpenVINO API documentation. |
@jgespino I cannot seem to find your screenshot. Did you run this using Windows or Raspberry Pi? I am able to run inference on images on Windows but not for Raspberry Pi, so I'm unsure if its a coding error or software error from OpenVINO. |
@Averen19 Sorry meant to attach it... I ran it on the Pi. The code is using OpenCV to read the video/image file, can you check if the version on your windows system is the same from the one on your pi? |
The version of OpenVINO on my Windows is 2021.4.752 while the one you provided was 2021.4.2, do you think that would affect the inferencing? |
@Averen19 That is the same release of OpenVINO 2021.4.2. I was referring to the OpenCV, did you install a different version or are you using the included OpenCV version? |
Im using the include OpenCV version, not custom installed. |
@jgespino The OpenCV version I'm currently using is OpenCV 4.5.3, is this support with this version of OpenVINO? |
@Averen19 Apologies for the delay, so the issue seems to be with OpenCV version 4.5.3-openvino which is part of OpenVINO 2021.4.2 release. However, building OpenCV version 4.5.5-openvino does not seem to have this issue. See below. My recommendation is to build OpenCV 4.5.5-openvino from source and comment out line 69 to line 77 in the setupvars.sh script to not configure the pre-built OpenCV.
|
@jgespino could you please explain what --ouput Conv_198,Conv217,Conv_236 is doing in the command: I am trying to convert yolov5m / yolov5n / yolov5l for the NCS2 stick but these Conv_xxx layers do not exist and I fail to get it working. Thanks! |
@maecky From the model optimzier:
I am specifying the new outputs for this model, the ops/layer names can be found using a model visualizer like neutron. You can find more information here: https://github.com/violet17/yolov5_demo#convert-onnx-file-to-ir-file |
@jgespino Has the 2022.1 package been uploaded. I am having the same issues and have been trying to solve myself over the last few weeks. I got to the point of building everything from sources on Ubuntu 18.0.4 on the Pi and am still running into a bunch of errors. |
@jgespino Just tried installing OpenVINO 2022.1 on Raspbian and came across this error. `ERROR: Cannot install openvino-dev==2021.3.0, openvino-dev==2021.4.0, openvino-dev==2021.4.1, openvino-dev==2021.4.2 and openvino-dev==2022.1.0 because these package versions have conflicting dependencies. The conflict is caused by: To fix this you could try to:
Please advise how to bypass these strict dependancies |
@Carson-Bay The OpenVINO for Raspbian OS package has not been uploaded yet. I recommend building the package from source. You can follow the instructions on this guide.
The pip package is not compatible with Rasbpian OS, see the system requirements:
I am closing this discussion, please start a new issue if you need additional assistance. |
HI,
I'm trying to run my custom YOLOv5s model on a RPI4 with NCS2, I have converted the model using the default export.py file from Ultralytics, I tried to do inferencing on PC before moving to RPI and I get such an error. Do you think you can help me with this? Or maybe you can send a demo code to do inferencing with the YOLO model? The following is also the code I used to do detection.
test.zip
The text was updated successfully, but these errors were encountered: