Custom video processing board

Question/Issue:

*root@sama5d3-eds-sd:~/linux-sdk-python/examples/image# python3 classify-video.py cverman69-project-1-linux-armv7-v2.eim /dev/video0 *
MODEL: /home/root/linux-sdk-python/examples/image/cverman69-project-1-linux-armv7-v2.eim
Traceback (most recent call last):

  • File “/home/root/linux-sdk-python/examples/image/classify-video.py”, line 108, in *
  • main(sys.argv[1:])*
  • File “/home/root/linux-sdk-python/examples/image/classify-video.py”, line 47, in main*
  • model_info = runner.init()*
  • File “/usr/lib/python3.10/site-packages/edge_impulse_linux/image.py”, line 19, in init*
  • model_info = super(ImageImpulseRunner, self).init()*
  • File “/usr/lib/python3.10/site-packages/edge_impulse_linux/runner.py”, line 41, in init*
  • return self.hello()*
  • File “/usr/lib/python3.10/site-packages/edge_impulse_linux/runner.py”, line 56, in hello*
  • return self.send_msg(msg)*
  • File “/usr/lib/python3.10/site-packages/edge_impulse_linux/runner.py”, line 79, in send_msg*
  • data = self._client.recv(1 * 1024 * 1024)*
    ConnectionResetError: [Errno 104] Connection reset by peer

1- Why does the runner.py file utilize sockets and does it connect to an edge impulse server? I thought all of this python inference was done locally.

2- What is the likely cause of this issue and how would you recommend I go about fixing it? I noticed the line where my error occurs is one of the few areas in the runner.py source that is commented… Maybe this has had issues in the past??

Screenshot from 2024-03-23 17-41-57

3 - Does edge impulse have a resource that explains the performance difference when interacting with Linux.eim models via the three different SDKs? I.e., like a table or something that compares the difference in speed when using NodeJS, Python, and GO for the exact same model?

Project ID:

331077

Context/Use case:

Hey guys. I’m fairly new to edge impulse within the last year so forgive me if there is documentation out there that covers these questions. So far I haven’t found anything. I’m currently in the prototyping stage of developing my own PCB with Linux capable MPUs (Armv7) for the host ICs. The intended application will involve simultaneous processing of 4+ FFMPEG streams across Ethernet. Anyways… most of my work up to now has involved testing the various ways I can integrate edge impulse software onto my host images. I have come to the following conclusion. The two easiest ways to run an impulse right out of the box are either to 1 - Install the edge-impulse-sdk through NPM. This gives you a binary which can be launched and seems to work seamlessly. The only con would be that NPM can hang during installation on hardware that hasn’t been tested yet (not sure if it is even meant to work that way). 2 - Install the edge-impulse-sdk through pip. Once the wheel built from source .tar is installed… You should have access to libraries that you can use to run python examples (like the ones shown in the repository GitHub - edgeimpulse/linux-sdk-python: Use Edge Impulse for Linux models from Python. My general understanding is that the node binary will connect to the edge impulse website through JSON/HTTP requests. On the other hand, I’m not exactly sure how the python example scripts work… At first I assumed it was all local inference because I ran the classify-video.py script with a linux(x86) .eim model and v4l2 usb cam. Everything worked fine. A bounding box window popped up and I see the axis info printed in my terminal. However, when I switched over to the development board I am using and tried to recreate the same steps (with a Linux(armv7) .eim this time), I receive the error shown above.

My past experience with similar “connection reset” errors leads me to believe this is some kind of web socket issue. The board is able to download packages, ping the internet fine, resolve DNS, etc… So I’m not sure what the issue would be. From what I have read, recv() is used to to receive messages from a socket so that leads me to the questions I asked.

Just as a reminder… This is NOT one of the officially supported development boards that I am testing the software on.

1 Like

Hi @cverman69

Awesome to hear that you want to support your design on our platform.

If you are interested in integrating or creating your own custom board that is supported by our platform officially or unofficially let me try to get some attention here from our embedded team so we can find the pathway that best suits your project / team.

Is this for personal business or university usage?

Are you an embedded engineer or embedded systems integrator / designer?

The reason for these questions is to find out if you want to work with one of our recommended services companies, solutions, sales, or university program teams

@Arjan fyi can you please advise on the best approach for self service?

Best

Eoin

1 Like

Hello @Eoin

This is a personal project at the moment. That being said, I do see it having business potential down the road if I could get everything working to my expectations. My official job is an application engineer at one of the large semiconductor firms. This project is not related to those responsibilities.

Is there is any particular service you recommend for helping me progress? I’m okay with just asking questions in the forum for now.

Thanks

1 Like

Hi @cverman69

Thats perfect, before even self serve lets just get you some debbugging steps so we can find where the problem lies.

You mentioned about connection issues? The eim contains your model or impulse so no connection is required to run the machine learning algorithm, why is the connection important here?

That error looks like you’re getting too many requests sent:

Pull back to the bare minimum test of running an impulse on that custom hardware before trying to go all in on video and connectivity.

Post your complete code if you want specific help with the connectivity part as a gist or notebook.

Best

Eoin

@cverman69,

The 2rd argument to classify-video.py should be a video file and not the camera device id.
In that case you should use classify-full-frame.py. Pass -h for more information.

classify-video.py and the other examples are standalone and do not require any network. They only try to connect to a UNIX socket created by the EIM.

Looking at your logs it appears that the connection is resetted/closed by the EIM (for some reason) and hence the error. It fails by the first frame (hello). For this we need to debug and get the stdout of the EIM.

To debug, please follow the instructions in Linux EIM Executable | Edge Impulse Documentation in Debugging with stdout section. That is,
In terminal 1:

chmod u+x <your-model-eim>
./<your-model-eim> /tmp/hello.sock

and in terminal 2:

python3 classify-full-frame.py /tmp/hello.sock /dev/video0

Note: If you have single camera device you can omit the camera device id.

Grab and share the debug information returned in terminal 1.

// Raul

Hello @Eoin @rjames,

Thank you for the feedback. I moved on from debugging the socket issue on the armv7l platform. As a side note… I think I have decided to pivot to using an aarch64 chip as the nodejs functionality seems to be more consistent on those devices. After reading Raul’s recommendation I started using classify.py and classify-full-frame.py which gives me much better results in terms of latency (this observation makes sense because the video script is specifically for playback of a video file… i.e., not a live capture device) I will attach some examples I have where I’m running models:

1- FOMO


2- MobileNetV2SSD


This leads me to my new questions I have:

  1. I have had a hard time of training a FOMO model into getting good results. I have tried changing all sorts of variables such as # of epochs, batch size, learning rate, amount of data, etc. No matter what parameters I change, the F1 score seems to peak somewhere in between .4 and .6. Do you have any ideas what could be causing this to happen? I’m guessing it has to do with the feature generation of my dataset. Most of the examples I see on your website show a distinct separation between the different classes like this

image

However, my data is always bunched as one massive clump like this

I’m not sure why this is the case. Right now, a lot of the images I’m using are pulled from random datasets on the web and hence the images are of varying resolution and size. I didn’t originally think this was going to be an issue because of the processing steps done by edge impulse… Maybe I was wrong. Should I try with a more uniform dataset? In the meantime… I will just use the MobileNetV2 model. I switched over to that today and was able to get an F1 score of .8 with very little effort.

  1. When I ran the bad FOMO models on local devices… I noticed it still seems to be showing a bounding box (instead of the circular centroid that can be seen when running live classification). The bounding boxes do seem to be a lot smaller so I’m guessing the outline is still around the centroid but the shape is a box due to the formatting of the tensorflow functions used inside the python script. Is this correct? I imagine there is an easy way to change this but I’m not sure where to look.

Sorry for the delayed response. The help is much appreciated!

Michael S