Testing YOLO11n in Visual Object Detection and setting up Gazebo Jetty with Stable-Baselines3
These days I have focused on completing the Visual Object Detection task by testing the YOLO model, and on setting up the environment to start working with Gazebo Jetty and Stable-Baselines3.
Testing YOLO11n in Visual Object Detection
To finish this activity, I fine-tuned a YOLO11n model and exported it to ONNX.
To work with the same dataset used for the MobileNet model, I first had to convert the Open Images CSV annotations (corner coordinates, one row per box) into YOLO format, as required by the Ultralytics detection documentation. This format uses one .txt file per image, with one line per object: class x_center y_center width height, normalized between 0 and 1.
CSV to .txt parser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pandas as pd
import os
def convert_split(csv_path, labels_out_dir):
os.makedirs(labels_out_dir, exist_ok=True)
df = pd.read_csv(csv_path)
for image_id, group in df.groupby("ImageID"):
lines = []
for _, row in group.iterrows():
x_center = (row["XMin"] + row["XMax"]) / 2
y_center = (row["YMin"] + row["YMax"]) / 2
width = row["XMax"] - row["XMin"]
height = row["YMax"] - row["YMin"]
lines.append(f"0 {x_center:.6f} {y_center:.6f} {width:.6f} {height:.6f}")
with open(os.path.join(labels_out_dir, f"{image_id}.txt"), "w") as f:
f.write("\n".join(lines))
src = "/home/hectormc/IA_Jderobot/dataset-person"
dst = "/home/hectormc/IA_Jderobot/dataset-person"
convert_split(f"{src}/sub-train-annotations-bbox.csv", f"{dst}/labels/train")
convert_split(f"{src}/sub-validation-annotations-bbox.csv", f"{dst}/labels/val")
convert_split(f"{src}/sub-test-annotations-bbox.csv", f"{dst}/labels/test")
Once the dataset was ready, I followed the Ultralytics guide for fine-tuning a YOLO model and tested the result, as shown below.
YOLO11n Visual Object Detection test video
Comparing MobileNetV1-SSD and YOLO11n, I found that MobileNetV1-SSD was more accurate and more efficient at detecting people in the camera feed.
Setting Up Gazebo Jetty with Stable-Baselines3
I have also been getting ready for the Follow Line RL project. To start it, I used a prepared Docker image with Gazebo Jetty and ROS Lyrical installed.
With the image built and the container running, I installed Stable-Baselines3 and cloned a GitHub repository with an example exercise on the cart pole.
In the coming days, I will replicate this Gazebo world, work out how the example code works, and write the code to train a reinforcement learning model.