Custom Vision Model Training and Deployment Based on Roboflow and HUSKYLENS 2

1.1 Project Introduction


If you want HUSKYLENS 2 to identify custom objects such as apples, a custom object detection AI model is required. Traditional model training demands substantial technical know-how: developers must set up intricate runtime environments, manage dataset formatting, and debug countless compatibility problems, which creates a high threshold for beginners and hobbyists.
This tutorial adopts Roboflow as our cloud vision workflow platform. It integrates image annotation, dataset management and model training in one browser-based workspace. Roboflow conveniently outputs standardized YOLO annotation datasets and PyTorch.pt weight files, removing the burden of manual dataset sorting and local training setup.
Custom recognition models built by this pipeline have wide practical uses. You can adapt this solution for fruit sorting, item inventory checking, simple access recognition, robot obstacle identification and maker education demonstrations. This guide walks you through the whole pipeline, so by the end you will have a fully functional custom recognition model running on your HUSKYLENS 2.


1.2 Demonstration Video

 

2 Principle of Project Implementation


This project has three simple steps to make HUSKYLENS 2 recognize your custom object:
Collect Data (HUSKYLENS 2): Use the HUSKYLENS 2 camera to record a video of your target object (like an apple).
Train the Model (Roboflow Platform): Upload your images to the Roboflow website, annotate objects and run cloud training. Roboflow exports the YOLO-format dataset and trained `.pt` PyTorch weight file.
Convert & Install (Terminal + Package Generator): Download the `.pt` model weight to your PC. Convert the `.pt` file to `.onnx` via terminal commands, then use the DFRobot tool to convert and pack it into a zip file. Finally, copy this file to the HUSKYLENS 2 to install it.

 

 

3 Software & Hardware Preparation
3.1 Hardware List and Connection

HARDWARE LIST
1 HUSKYLENS 2
1 USB cable

 

3.2 Software Platform Preparation

 

- NET 7.0

 

- HUSKYLENS2_Package_Generator

 

 

- Roboflow

 

 

3.2.1 Roboflow Platform Account Registration


Open the link on the webpage and sign up for an account: Roboflow

 

 

3.2.2 Microsoft .NET SDK 7.0 Environment


Download the Microsoft .NET SDK 7.0 environment, the link is as follows:Download .NET 7.0 (Linux, macOS, and Windows) | .NET


The DFRobot Generator requires the .NET 7.0 SDK to run.
Download the SDK 7.0.410 (Windows x64) from the official Microsoft website.

 

 

Run the installer and follow the default setup.


Note:
.NET is a background runtime environment and does not have a graphical user interface (GUI). You won't find an icon on your desktop, and you cannot "open" it directly. This is completely normal.
Check if the installation was successful:
Since .NET has no graphical interface, you can verify it using the Command Prompt:
Press Win + R to open Command Prompt.
Type the following command and press Enter:


dotnet --version

 

 

If it returns a version number (e.g., 7.0.410), the installation is successful.

 

3.2.3 HUSKYLENS 2 Package Generator


The Generator is used to pack the ONNX model and dataset into a .zip file for the hardware.
Download the HUSKYLENS2_Package_Generator.zip from the official DFRobot website.
Extract the .zip file to a local folder.
The software link is as follows:
https://gitee.com/dfrobot/onnx2kmodel/releases/download/v1.0/HUSKYLENS2_Package_Generator.zip

 

 

4 Model Training and Export

4.1 Data Collection and Annotation

4.1.1 Gather videos


Tap Camera on the HUSKYLENS 2 screen to enter the camera interface.

 

 

Switch to Video mode, and press Button-A to start recording.

 

 

For this tutorial, we will record a 1-minute video of an apple.
Recording Tips: Slowly rotate the apple to capture different angles, and keep the background as clean as possible.
After recording, connect HUSKYLENS 2 to your PC via USB. You can find the video in the folder: HUSKYLENS\storage\photo.

 

 

4.1.2 Upload and Annotate on Roboflow Platform


Click on “New Project” in the left sidebar.

 

 

Name your project and then click to create a private project.
For the project type, choose object detection.

 

 

Go to the Upload tab and drag your recorded video into the page. Roboflow will automatically extract frames from it.

 

 


4.2 Annotation Model


Wait for the video to upload, then click “Save and Continue” in the top right corner.

 

 

On the Unassigned Media page, click the “Start Annotating” button in the top right corner

 

 

On the Auto Label page, type apple in the Class name box.
Select “Auto Label” from the right panel.
Click “Run Preview” in the top right corner.

 

 

The AI will generate a preview with a bounding box around the apple. If it looks good, click "Label Batch" in the top right corner.

 

 

A pop-up will ask you to confirm the Auto Label Job (it uses a tiny amount of credits). Click "Start Auto Label" at the bottom.

 

 

Wait a few moments. Once the AI finishes labeling the entire batch, click “Add Approved To Dataset” in the top right corner.
A pop-up will ask you to split the images. Keep the default 70/20/10 (Train/Valid/Test) ratio and click “Add Images”.

 

 

4.3 Generate and Export Dataset


In the left navigation bar, select Versions to access this page.

 

 

The HUSKYLENS 2 package generator only accepts input sizes of 224×224, 320×320 and 640×640. We recommend using 640×640 for better recognition performance.
Locate the Resize option in the preprocessing section when creating a new dataset version. The default resize setting here is 512×512. Click its “Edit” button and set the resolution to 640×640.
No need to change the other settings, just click “Continue”.

 


Finally, click “Create”.

 

 

On the version page, click "Download Dataset".
Select "YOLOv11" and click "Download zip". This will download the standard YOLO dataset directly, with no code needed.

 

 

Export the YOLOv11-formatted dataset ZIP package for the DFRobot HUSKYLENS 2 package generator.


4.4 Cloud Model Training


After waiting for the creation to succeed, we click on “Train Model”.

 

 

Select Custom training.

 

 

On the Select Architecture page, find YOLOv11 and set Model Size to Nano.
Note: Make sure you select Nano, not Small. Small variant (YOLO11s) is unsupported by the HUSKYLENS 2 Package Generator and will trigger an error warning.

 

 

On the Pick Your Data page, select Current Dataset. This option loads your latest images and annotations.

 

 

This page means the training task has begun. You will receive an email notification after training finishes. Select View Training to monitor the training progress.

 

 

4.5 Download Weights and Convert to ONNX


Your model training is finished. Click Download Weights to get the .pt model file for later conversion and packaging for HUSKYLENS 2.

 

 

Select Deploy on my own infrastructure, then click Continue.

 

 

Click Download Anyway to obtain the raw model weight file. Do not select Deploy With Roboflow, as that uses Roboflow's built-in inference service.

 

 

Check the box I understand I am responsible for licensing and deployment outside Roboflow, then click Download to get your model weight file. We will convert this downloaded .pt file to .onnx using a terminal command in the following steps.

 

 

Step 2: Convert the Model to ONNX
Roboflow provides the model as a .pt file. Because HUSKYLENS 2 requires an .onnx file, we need to convert it using the terminal.
Click "Download Weights" on the model page to get weights.pt.
Open Command Prompt (cmd) and navigate to your folder:


cd /d C:\Users\YourName\Desktop


Note: Replace C:\Users\YourName\Desktop with your actual local folder path where your weights.pt file is saved.
Install the required library (skip if already installed):


py -m pip install ultralytics

 

 

Run this command to export:


py -c "from ultralytics import YOLO; YOLO('weights.pt').export(format='onnx', nms=None, simplify=True)"


Note: This is a single-line terminal command. Do not insert manual line breaks even if it visually wraps in your document.
Wait for ONNX: Export complete

 

 

5 Generate the installation package and deploy the hardware

5.1 Package the installer


Now we have both the ONNX model and the converted YOLO dataset. Let's pack them together.
Open the HUSKYLENS 2 Package Generator.

 

 

Crucial Step: For Dataset Folder, select the root folder of your unzipped YOLO dataset downloaded from Roboflow.
ONNX Model (.onnx): Select the .onnx file.
Model Version: Select YOLO11n. Task Type: Select Detection.

 

 

If you encounter the warning shown in the screenshot, open the data.yaml file inside your YOLO dataset folder and edit it.

 

 

This error comes from the ../ relative paths inside the data.yaml file exported by Roboflow. The HUSKYLENS 2 package generator cannot parse paths starting with ../. Simply delete the ../ at the start of each path, matching the example shown in the screenshot. Save the modified file, then reselect your dataset root folder in the generator.

 


             
App Name: Enter Apple in the English box. (Adding other languages is optional and not required for this tutorial).
Click Start at the bottom.

 

 

Once finished, a .zip installation package will be generated.

 

 

Note: Do NOT rename or modify the generated .zip file! Keep the original name exactly as it is, otherwise, the HUSKYLENS 2 will fail to recognize it.


5.2 Deploy Model to Hardware


Copy the generated .zip file to the HUSKYLENS\storage\installation_package directory.

 

 

On HUSKYLENS 2, open Model Installation, and then select Local Installation.

 

 

6 Demonstration

 

 

7 Attachment

icon Attachment.zip 2.52MB Download(0)
License
All Rights
Reserved
licensBg
0