In computer vision, there are many generic, pre-trained models that can be deployed to edge devices (such as OpenCV AI Kit). However, the real power of today’s computer vision deployment lies in customizing and training your own computer vision models on your own data to apply custom solutions to your own devices.

To train your own custom models, you must collect a dataset of images, annotate them, train your model, and then transform and optimize your model for your deployment destination. This machine learning approach is full of nuance and slows down development cycles. More importantly — errors don’t show up as outright errors, but quietly degrade your model’s performance.

To simplify computer vision development and deployment, Roboflow, OpenCV and Luxonis are working together to provide one-click customized training and deployment solutions for OAK-1 and Oak-D.

Luxonis OpenCV AI Kit equipment –OAK-D (left) and OAK-1 (right).

In this blog post, we’ll walk through the process of deploying custom models to OAK devices and show how seamless it is.

Best of all, you don’t need OAK equipment to develop your project today. You can develop and test in Roboflow’s cloud environment before deploying your trained models to OAK.

Step 1: Gather your data set

To train your custom model, you need to collect images that represent the problems your model is trying to solve in the field. It is important to use images that are similar to your deployment environment. The best practice is to train the image on your OAK device at the resolution you wish to infer. You can automatically upload images from your OAK to Roboflow for annotation via the Roboflow Upload API.

If you only have a feeling for one problem, you’ll need 5-100 images. To build a production-level system, you may need more images.

Step 2: Annotate your data set

The next step is to upload and annotate your images in Roboflow.

Upload data to Roboflow after creating a new data set – Roboflow supports a variety of formats

Mark data in Roboflow

You will draw a bounding box around the object you want to detect. See our tips on best practices for labeling.

Step 3: Edit your data

Once you are satisfied with the annotations for your dataset, you can create a version of the dataset in Roboflow to prepare for the training. Versions of the dataset are locked in time, allowing you to iterate over the experiment because you know the dataset has been fixed at version time.

When creating the version of the dataset, you will make two sets of decisions.

  • Preprocessing – selection of image standardization throughout the data set, such as image resolution. For OAK deployments, we recommend a 416×416 image resolution.
  • Enhancement – Image enhancement creates new, transformed images from your training set, exposing your model to different data changes.

Preprocessing and enhancement options in Roboflow

Step 4: Train and deploy your model to OAK

Roboflow trains provide single-key training and deployment to OAK equipment. After you have created a version, click Start Training and select a checkpoint to Start. If you don’t have a checkpoint to start with, simply select Train from Scratch or Public Models –> COCO

Start training in Roboflow

Depending on the size of your data set, the training and conversion will take between 15 minutes and 12 hours, and you will receive an email when completed.

An email informing you that your model has been trained and transformed.

Step 5: Test your model on a managed API

After Step 4, your model is ready for OAK deployment (Step 6), but we recommend spending some time testing your model on the Roboflow managed reasoning API before deployment. Hosted Inference API is a version of your model deployed on a cloud server. You can feel the quality of your reasoning on the test images and develop your application based on this API.

When you need edge deployment, you can go ahead and set up OAK inference server.

This also means that you don’t need your OAK in hand to start iterating through your model and testing deployment conditions.

Step 6: Deploy your model to the OAK device

Once your model is trained, it can be deployed to the edge of your OAK device.

Supported Devices

The Roboflow OAK Inference server runs on the following devices.

  • DepthAI OAK-D (LUX-D)
  • Luxonis OAK-1 (LUX-1)

The host system requires a Linux/AMD64 processor. Arm65 / ARCH64 support is coming soon.

Reasoning speed

In our tests, we observed a reasoning speed of 20FPS at 416×416 resolution, suitable for most real-time applications. This speed will vary slightly depending on your host.

Provide services for your model

On your host, install Docker. And then run.

sudo docker run --rm \
    --privileged \
    -v /dev/bus/usb:/dev/bus/usb \
    --device-cgroup-rule='c 189:* rmw' \
    -e DISPLAY=$DISPLAY \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -p 9001:9001 \
    roboflow/oak-inference-server:latest
Copy the code

This will start a local inference server on your machine, running on port 9001.

Use this server.

  • Verify that your OAK is correct by accessing it in your browser.http://localhost:9001/validate
  • The reasoning is verified by calling the built-in pre-trained COCO model.http://localhost:9001/coco
  • Call your custom model by retrieving the requesthttp://localhost:9001/[YOUR_ENDPOINT]?access_token=[YOUR_ACCESS_TOKEN]

When called, you can’t get an image or json response.

{' predictions' : [{' x ', 95.0 'y' : 179.0, 'width: 190,' height: 348, 'class' : 'mask', 'confidence' : 0.35}]}Copy the code

Example of image response (training data) that predicts the author is wearing a mask.

So, you’re off to the races. The real challenge begins with implementing your computer vision model in your application.

  • For more information on developing for OAK Inference servers, see the Roboflow OAK Inference Server documentation.

conclusion

Congratulations to you! Now you know how to deploy a computer vision model. Now you know how to deploy a custom computer vision model to the edge in a few clicks, with a tough machine learning pipeline.

Gain access

If you already have an OAK device, you can get started for free. Just apply for Roboflow Train directly in Roboflow and reply your OAK serial number to the email. If you don’t already have OAK equipment, please email us to get a discount).

Happy training! More importantly, have fun with your reasoning!

The postHow to Train and Deploy Custom Models to OAK with Roboflowappeared first onOpenCV.