Train an Object Detection Model
The Object Detection model can be used to locate the positions of objects in an image and classify the objects into different categories. This topic describes how to train an Object Detection model to locate and count rotors.
The workflow for training the Object Detection model is as follows:
Preparations
Before you start training, make sure you have acquired and selected the images for training according to the data acquisition standard. In this example, you need to prepare images of a bin that contains rotors.
Create a Project and Add a Module
-
Create a project: Open Mech-DLK. In the upper-left corner of the startup interface, click New Project, name the project, and select a directory to save the project.
-
Add a module: In the upper-right corner of the project interface, click in the Modules section, and then select the Object Detection module.
Import and Label the Image Data
-
Create labels: In the Labeling tab, click in the Classes section to create labels. In this example, create a label named Rotor because the model will be trained to recognize all rotors.
-
Import image data: On the upper part of the image list, click
, select some images and import them into the project. -
Select an ROI:
-
On the labeling toolbar, click the ROI Tool , and adjust the frame to select the bin containing rotors in the image. The ROI should exclude irrelevant background and cover the target objects in the image with an appropriate margin.
-
Click in the lower-right corner of the ROI to apply the current ROI. The ROI settings will be applied to all images. Check that all rotors are consistently within the ROI. Otherwise, adjust the ROI again.
-
-
Label images: You can use the Pre-trained Labeling Tool to reduce manual labeling time. Start by manually labeling some images, then train the model to label the remaining images.
-
Manually label images: On the labeling toolbar, right-click , then click the Rectangle Tool . Label the bounding rectangle for each rotor on the images.
-
Train the model for labeling: In the lower-right corner of the interface, click Train and Validate to start the training and validation of the labeling model.
-
Use the Pre-trained Labeling Tool: After you validate the model, import the remaining images, and click the Pre-trained labeling button to start image labeling. After labeling is complete, check each image with pre-trained labels. If any rotors are not labeled, you need to manually label them.
-
-
Split the dataset: After all images are imported and labeled, click and drag the slider to split 80% of the images in the dataset into the training set, and the rest 20% into the validation set.
Train the Model
After the images are imported and labeled, you can start training the model.
-
In the Training tab, click
, and enable Max num of training objects, which limits the maximum number of objects that can be recognized during training. Adjust the parameter value based on the actual situation. -
Click the Train button to train the model again. You can click Training Center to view the training progress, or click Show chart to view training accuracy and loss parameters by epochs.
Validate and Export the Model
After the model is trained, in the Validation tab, click the Validate button, Mech-DLK will validate the model with the current data.
After the validation is complete, check the validation results for accuracy. An Object Detection model is successfully trained to locate and count rotors.
In the lower-right corner of the Validation tab, click Export, and select a directory to save the exported model. The exported model can be used in Mech-Vision and Mech-DLK SDK. Click here to view the details.