Welcome to RDK S600 Developer Kit repository
09.Dataset annotation
Dataset Annotation
Dataset Annotation1. Dataset Collection1.1 Extracting Images1.2 Dataset Path2. Using Label Studio2.1 Installing Label Studio2.2 Starting Label Studio2.2.3 Accessing Label StudioHost MachineSame Local Area NetworkFirst-Time Use3. Dataset Annotation3.1 Create Project3.2 Project Name3.3 Import Training Set3.4 Label Settings3.5 Dataset Annotation3.6 Export Dataset3.7 Dataset Directory Structure3.8 Dataset Configuration FileReferences
For recognizing specific objects or improving object recognition accuracy, users need to train the model themselves. Dataset collection and annotation are indispensable parts of this process.
1. Dataset Collection
Description: For recognition in specific scenarios, users can use a camera to record videos of objects from various angles, then extract frames from the video as the training set.
1.1 Extracting Images
A simple example: Extract one frame from the video every 15 frames as the dataset.
ximport cv2import os
# Path to the input video filevideo_file = '/home/sunrise/ultralytics26/data/yahboom_data/orange_video/orange.mkv'
# Path to the output folder to save the framesoutput_folder = '/home/sunrise/ultralytics26/data/yahboom_data/orange_pic'
# Check if the output folder exists, if not, create itif not os.path.exists(output_folder): os.makedirs(output_folder)
# Open the video file using OpenCVcap = cv2.VideoCapture(video_file)
# Get the total number of frames in the videototal_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
# Get the frames per second (fps) of the videofps = cap.get(cv2.CAP_PROP_FPS)
# Frame counter to keep track of the current frame numberframe_number = 0
# Define the interval for extracting frames (every 15th frame)frame_interval = 15
# Initialize a new counter for saved frames (starting from 1)saved_frame_number = 1
while True: ret, frame = cap.read()
# If the frame is not successfully read, exit the loop if not ret: break
# Save every 15th frame if frame_number % frame_interval == 0: # Format the frame number starting from 1 (e.g., 1.png, 2.png) image_name = f'{saved_frame_number}.png' image_path = os.path.join(output_folder, image_name)
# Save the current frame as a PNG image cv2.imwrite(image_path, frame) print(f'Saving frame {frame_number}/{total_frames} as {image_name}')
# Increment the saved frame counter saved_frame_number += 1
# Increment the frame counter for the video frame_number += 1
# Release the video capture objectcap.release()
# Print message when processing is completeprint("Video processing complete! Every 15th frame saved as an image!")1.2 Dataset Path
Example video: /home/sunrsie/ultralytics26/data/yahboom_data/orange_video
Example images: /home/sunrise/ultralytics26/data/yahboom_data/orange_pic
2. Using Label Studio
Label Studio is an open-source data annotation platform used for data labeling and annotation task management, supporting various types of data input and annotation formats.
2.1 Installing Label Studio
xxxxxxxxxxpip install label-studio -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com --break-system-packages
2.2 Starting Label Studio
Enter in terminal:
xxxxxxxxxxlabel-studio start

2.2.3 Accessing Label Studio
Host Machine
For RDX S600 series development board access method, first-time users need to enter their own username and password.
xxxxxxxxxxhttp://localhost:8080/

Same Local Area Network
Devices on the same local area network can access via the board IP:8080.
xxxxxxxxxxhttp://Board IP:8080/ # For example: http://192.168.2.99:8080/

First-Time Use
First-time users need to register and login. Factory default account information (account information is fictional):
xxxxxxxxxxAccount: yahboom@163.comPassword: yahboom@163.com


After registration, the website will automatically log in:

3. Dataset Annotation
The demonstration dataset is on the development board, so access Label Studio from the board.
3.1 Create Project

3.2 Project Name
The project name can be freely chosen based on your training set:

3.3 Import Training Set
Manually import the prepared dataset: Do not import too many images at once. It is recommended to select 50-100 images each time, then import multiple times.

3.4 Label Settings
Since we are demonstrating orange recognition, select "Object Detection".

Delete built-in labels:

Add new labels:

3.5 Dataset Annotation
Click "Annotate all tasks":

Annotation steps: First click the "Orange" label, then use the mouse to draw a bounding box around the corresponding orange in the image. After completion, click Submit to proceed to the next annotation.

If the bounding box does not completely enclose the orange, you can click on the bounding box to adjust the position of each edge:

3.6 Export Dataset
Select YOLO format to export. The browser will automatically download a compressed package.


3.7 Dataset Directory Structure
The directory structure corresponding to the compressed package exported from Label Studio:
xxxxxxxxxx.├── images├── labels├── classes.txt└── notes.json
You need to split the images and labels exported from Label Studio into train (training set) and val (validation set), with an approximate ratio of 8:2. The images and labels in both train and val need to have matching names.
xxxxxxxxxx.├── classes.txt├── notes.json├── train│ ├── images│ └── labels└── val├── images└── labels
3.8 Dataset Configuration File
Contains paths to the training set and validation set, as well as the number and names of classes.
xxxxxxxxxxpath: /home/sunrise/ultralytics26/data/yahboom_data/orange_datatrain: train/imagesval: val/imagesnc: 1# Classesnames:0: Orange