https://studio.edgeimpulse.com/public/40479/latest
To collect your own device, you can use your mobile phone by going to the Devices tab and click on + Connect a new device. Select Use your mobile phone and flash the QR Code. You can also select Use your computer, it will open a web page so you can directly capture new images using your computer's camera. The images will directly arrive in your Data acquisition's project tab.
See use your mobile phone documentation page.
If you want to upload data that already contains bounding boxes, the uploader can label the data for you as it uploads it. In order to do this, all you need is to create a bounding_boxes.labels file in the same folder as your image files. The contents of this file are formatted as JSON with the following structure:
{
"version": 1,
"type": "bounding-box-labels",
"boundingBoxes": {
"mypicture.jpg": [{
"label": "person",
"x": 119,
"y": 64,
"width": 206,
"height": 291
}, {
"label": "person",
"x": 377,
"y": 270,
"width": 158,
"height": 165
}]
}
}
For this project, we have used a subset of the public MS COCO 2017 dataset.
You can find here a Google Colab link that downloads the dataset on Google Servers, extract the Person images and bounding boxes to Edge Impulse format and upload it to your Edge Impulse project: Google Colab link.
You will need:
- To create an Edge Impulse ingestion API key for your project:
- To create an account on Roboflow to download the public dataset using the Yolo v5 PyTorch format:
- To execute the Google Colab notebook:
You can find a full tutorial to build an Object Detection machine learning pipeline on Edge Impulse documentation website: Detect objects with bounding boxes
There is also a video available:
To run the inference on your device, we will see two different methods:
- Edge Impulse Linux CLI to verify that your model is working
- Edge Impulse Python SDK to customize your application
To install the Edge Impulse Linux CLI, you will need NodeJS v14 or higher and edge-impulse-linux
npm package. See our Edge Impulse for Linux guide to install the CLI on your device.
Once installed, just run:
edge-impulse-linux-runner --clean
Follow the prompt, it will build in Edge Impulse servers your model according to your operating system and download the binary for you:
luisomoreau@Louiss-MacBook-Pro ~ % edge-impulse-linux-runner --clean
Edge Impulse Linux runner v1.3.1
? What is your user name or e-mail address (edgeimpulse.com)? louis
? What is your password? [hidden]
? From which project do you want to load the model? Louis Moreau / Intrusion Det
ection - Workshop Le Wagon
[RUN] Downloading model...
[BLD] Created build job with ID 2845183
[BLD] Writing templates...
[BLD] Scheduling job in cluster...
[BLD] Job started
[BLD] Exporting TensorFlow Lite model...
[BLD] Exporting TensorFlow Lite model OK
[BLD]
[BLD] Removing clutter...
[BLD] Removing clutter OK
[BLD]
[BLD] Copying output...
[BLD] Copying output OK
[BLD]
[BLD] Scheduling job in cluster...
[BLD] Job started
[BLD] Building binary...
[BLD] o64-clang++ -MD -Wall -g -Wno-strict-aliasing -I. -Isource
...
[BLD] Building binary OK
[RUN] Downloading model OK
[RUN] Stored model version in /Users/luisomoreau/.ei-linux-runner/models/105817/v1/model.eim
[RUN] Starting the image classifier for Louis Moreau / Intrusion Detection - Workshop Le Wagon (v1)
[RUN] Parameters image size 320x320 px (3 channels) classes [ 'person' ]
? Select a camera HD Pro Webcam C920
[RUN] Using camera HD Pro Webcam C920 starting...
[RUN] Connected to camera
Want to see a feed of the camera and live classification in your browser? Go to http://192.168.1.196:4912
boundingBoxes 37ms. [{"height":171,"label":"person","value":0.9868184924125671,"width":236,"x":8,"y":148},{"height":142,"label":"person","value":0.6588833928108215,"width":130,"x":81,"y":168},{"height":153,"label":"person","value":0.6112269163131714,"width":263,"x":0,"y":123}]
Click on the provided local link (here http://192.168.1.196:4912)
For this workshop, we built a small Python application that will run the inference on your device and display a web page with the results. You can freely customize this application as you wish to create something that specifically match your business logic!
To run the application you will need to install Python3 its package manager pip3
.
Clone this repository locally:
git clone https://github.com/luisomoreau/workshop-intrusion-detection
cd workshop-intrusion-detection/
Install the dependencies:
pip3 install -r requirements.txt
You will also need to install flask
:
pip3 install -U Flask
Download your custom model at the root of this repository:
edge-impulse-linux-runner --download modelfile.eim
And run the application:
python3 app.py
Note: If you have several webcam attached to your computer, you can change the index of your camera in app.py
line 13: videoCaptureDeviceId = int(0) # use 0 for web camera
. You can also import a video stream and adapt the code easily, feel free to have a look at our python images example.
Note 2: If you are planning on using this on a distant device and don't have access to a monitor connected to that device, replace the last line with: app.run(host="0.0.0.0", debug=True)
, it will broadcast the web application to your local network.
Happy coding!