Training and Deploying Custom Vision Models to HUSKYLENS 2 via Ultralytics Platform

1.1 Project Introduction


Training models on the Ultralytics Platform is remarkably smooth—deploying them to embedded hardware is often where the real friction begins. Environment setup, format adaptation, cross-compilation: the cumulative effort can quickly erode momentum. With HUSKYLENS 2, however, the process is considerably more straightforward. Models exported from the platform cannot run directly on the device, but a lightweight Python script for format conversion and the official DFRobot packaging tools are all it takes to get your model running on the hardware. This tutorial walks you through the complete pipeline—from data collection to generating a ready-to-use installation package—so that the model you trained on the Ultralytics Platform can recognize exactly what you taught it to, right 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 (Ultralytics Platform): Upload the video to the Ultralytics website. The cloud AI will learn what your object looks like and build a model for you.
Convert & Install (Package Generator): Download the trained model to your PC. 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 

 

Ultralytics Platform

 


Visual Studio Code    

 


.NET 7.0

 

 

HUSKYLENS2_Package_Generator

 

 

3.2.1 Ultralytics Platform Account Registration


Open the link on the webpage and sign up for an account: platform.ultralytics.com

 

 

3.2.2 Microsoft .NET SDK 7.0 Environment


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.

 

3.3.3 HUSKYLENS 2 Package Generator

 

The Generator is used to pack the ONNX model and dataset into a .zip file for the hardware.
Download and extract the HUSKYLENS 2 Model Installation Package Generator using the link below:
https://gitee.com/dfrobot/onnx2kmodel/releases/download/v1.0/HUSKYLENS2_Package_Generator.zip


3.3.4 VS Code Environment

 

To run our conversion script, we need Visual Studio Code.
Download and install Visual Studio Code.
Open VS Code, click the Extensions icon (or Ctrl+Shift+X).
Search for "Python" (by Microsoft) and click Install. This will automatically configure the Python environment for you.

 

4 Model Training and Export


4.1 Data Collection and Annotation


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.

 

 

Now, let's import the video and annotate the object.
Open your browser and log in to platform.ultralytics.com.

 

 

Go to Datasets and click Upload. Drag and drop your recorded video.

 


Once finished, click Create Dataset.

 


Auto Frame Extraction: The platform will automatically extract frames (about 1 frame per second) from your 1-minute video, generating roughly 60 images.
Annotation: Click on the generated images, use the "Draw" tool to draw a bounding box around the apple, and label it as apple. You must do this for all the images.

 

 

Draw a bounding box around the apple and label it as "apple".

 

 

4.2 Cloud Model Training


Once all your data is successfully annotated, you can start training the model.
Note: Cloud training consumes Ultralytics platform credits. New accounts receive “$5 free credits”. This tutorial only consumes approximately $0.04 of credit for one training run, which is well within the free allowance. Please confirm you have available credits before clicking Start Training.
Click the "New Model" button in the top right corner.

 

 

In the pop-up window, you can select the “yolo11n” as the base model.
Click "Start Training" in the bottom right corner.

 

 

Wait a few minutes for the cloud GPU to finish training. Once completed, your custom model is ready.

 

 

4.3 Export Model and Convert Dataset


After training is complete, we need to export the model and download the dataset from the platform. Since HUSKYLENS 2 requires the standard YOLO format, we will export the ONNX model first and then convert the downloaded dataset to prepare for deployment.


4.3.1 Export the ONNX Model


Find ONNX in the list and click Export.

 

 

In the pop-up window, change the precision to FP32. (HUSKYLENS 2 needs to compress the model. FP32 keeps the highest precision to prevent the model from failing on the hardware).
Click “Start Export” and download the .onnx file.

 

 

4.3.2 Download the Dataset


On your dataset page, click the Download dataset button in the top right corner to get the .ndjson file.

 


4.3.3 Convert the Dataset Format


Open VS Code and create a new folder.

 

 

Open the Python file named convert_dataset.py from the Attachment.

 

 

Drag the downloaded .ndjson file into the same folder.

 

 

Open the terminal in VS Code (Ctrl + ~). Install the required library by running:


py -m pip install ultralytics

 

 

Replace this filename with YOUR downloaded ndjson file name


Once installed, Change "nervous-ferret.ndjson" in the code to your actual downloaded file name. Run the script to convert the dataset:

 

 

Once you see Success! A new folder named Apple_YOLO_Dataset will be generated.

 

 

4.4 Package Generation


Now we have both the ONNX model and the converted YOLO dataset. Let's generate a model installation package for HUSKYLENS 2.


Open the HUSKYLENS 2 Package Generator.

 

 

Refer to the following figure to load the model and the accompanying dataset, and fill in the remaining parameters.

 


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 Hardware Installation and Deployment


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 


The following files are available in the attachment:

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