Skip to content

Model Training

paulnaebers edited this page Sep 24, 2025 · 4 revisions

Model Training

Data Collection

To train a custom TinyML model for detecting bike occupancy in the Leezenbox, we collected images from three main locations:

  • Leezenbox Mecklenbeck
  • Geoinformatics Department, University of Münster
  • Bicyclebox at Rudolf-Harbig-Weg 55

The goal was to capture diverse and representative data of bikes inside the parking boxes. During data collection, several issues emerged, which we addressed with targeted solutions:

  • Inconsistent camera angles & narrow field of view → switched to a better camera module with a broader angle to ensure full coverage of the parking spaces.
  • Cluttered bike arrangements → manual annotation ensured correct separation of bicycles and saddles.
  • Bikes outside the Leezenbox → excluded from labeling to avoid false positives.
  • Camera capture failures (in some cases the camera did not record images properly, which triggered automatic calibration in the wrong state (e.g., poor lighting conditions)). → introduced a calibration step that checks whether the camera successfully captured an image. If not, it resets the camera settings (white balance) after each shot and adds a short delay to allow stabilization.

Data Labeling

The dataset was manually annotated to ensure accuracy. We defined two main object classes:

  • Bicycles
  • Saddles

Labeling was performed carefully to exclude irrelevant objects and avoid bias. High-quality annotation was crucial to achieving better accuracy, reducing overfitting.

Dataset Preparation

  • Annotation format: YOLO
  • Augmentation: Rotation (90° and 270°) was applied to improve robustness against camera orientation. Further strategies like brightness adjustments and flipping were considered.
  • Final dataset: Combined images from both ESP camera modules and external security cameras to balance real-world and controlled conditions.

Hardware Setup

Microcontroller

We used the SEEED Studio XIAO ESP32S3 Sense, which was chosen for the following reasons:

  • TinyML ready: capable of deploying models directly on-device.
  • Camera integration: supports onboard image processing.
  • Wireless connectivity: Wi-Fi and Bluetooth support.
  • Modular I/O options: flexible for additional sensors and peripherals.
  • Core specs: Dual-core Xtensa® 32-bit LX7 processor, 8 MB PSRAM & Flash, USB-C support.

Components & Adjustments

During the project, several hardware modifications were made:

  • Camera module: Switched to a higher-quality module to improve image clarity and capture wider angles.
  • Storage: Tested different SD cards for reliable image storage and logging.
  • Power supply: Used 3.7V batteries for field testing.
  • Communication modules: Integrated LoRaWAN via WIO SX1262 kit for long-range data transmission.

System Architecture

The final hardware setup included:

  • MCU I (ESP32S3 Sense) → runs the detection model and communicates via BLE.
  • MCU II (ESP32 + LoRa module) → acts as BLE server, forwards detections via LoRaWAN to the gateway.
  • LoRaWAN Gateway → relays messages to the application server.
  • Web Application → displays bike occupancy statistics in real time.

Clone this wiki locally