AI-Based Trailer Identification
A machine learning system for automated truck trailer identification through barcode and sticker detection, designed for real-time edge inference on NVIDIA Jetson hardware. Developed as a Bachelor's thesis project within the TIDA5G initiative at Krone Business Center GmbH.
Problem Statement
During storage operations at Krone Business Center GmbH, trailers are occasionally lost or their positions are incorrectly entered into the existing software by Terberg drivers. These discrepancies lead to time-consuming search processes, delays, and increased operating costs. Manual inventory of trailers on storage yards is error-prone, costly, and disrupts the logistics chain.
The goal was to develop an automated, AI-powered solution that identifies trailers via their barcodes and stickers, even under varying lighting conditions, angles, and weather, and deploys directly on edge hardware mounted on yard vehicles.
System Architecture
Camera (Terberg / Drone)
β
βΌ
βββββββββββββββββββββββββββββββ
β NVIDIA Jetson Orin Nano β
β (8GB) β
β β
β βββββββββββββββββββββββββ β
β β TensorRT Engine β β
β β (Optimized Model) β β
β βββββββββββββ¬ββββββββββββ β
β β β
β βββββββββββββΌββββββββββββ β
β β Object Detection β β
β β Trailer + Barcode β β
β βββββββββββββ¬ββββββββββββ β
β β β
β βββββββββββββΌββββββββββββ β
β β Barcode Sequence β β
β β Extraction β β
β βββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββ
β
βΌ
Inventory System
Model Selection & Comparison
Three major object detection architectures were evaluated for suitability:
| Criterion | YOLO | Faster R-CNN | SSD |
|---|---|---|---|
| Speed | βββ Fastest | β Slowest | ββ Medium |
| Accuracy | ββ Good | βββ Best | ββ Good |
| Small Objects | β Weak | βββ Best | β Weak |
| Real-time Capability | βββ Excellent | β Limited | ββ Good |
| Edge Deployment | βββ Ideal | ββ Possible | ββ Good |
YOLO was selected as the primary architecture due to its real-time processing capability, critical for the Krone use case where trailers must be identified quickly without disrupting yard operations. Faster R-CNN was implemented as a secondary model for comparison.
Implementation
Three Model Approaches
-
Custom YOLOv8 (from scratch): Full implementation of the YOLOv8 architecture in PyTorch, including backbone (CSPDarknet-inspired), neck (PANet), head, and custom loss functions (CIoU + Distribution Focal Loss). This approach encountered challenges with tensor shape alignment and loss function implementation.
-
YOLOv8 Ultralytics: Using the Ultralytics library with pretrained weights and fine-tuning on custom datasets. This was the most successful approach, achieving >90% mAP.
-
Faster R-CNN (ResNet-50 + FPN): Using torchvision's pretrained Faster R-CNN with a custom classification head, fine-tuned on trailer and sticker datasets.
Custom YOLOv8 Architecture
The from-scratch implementation included these key components:
Input Image (416Γ416)
β
βΌ
βββββββββββββββββββββββββββββββ
β YOLOv8 Backbone β
β Conv β Conv β Conv β Conv β
β (3β64β128β256β512β1024) β
β β β
β SPPF Layer β
β (Multi-scale pooling) β
βββββββββββββββ¬ββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β YOLOv8 Head β
β Upsample + C2f blocks β
β Multi-scale detection β
β (P3, P4, P5) β
βββββββββββββββ¬ββββββββββββββββ
β
βΌ
[bbox, objectness, class]
per grid cell at 3 scales
Key architectural components:
- Conv: 2D Convolution + BatchNorm + SiLU activation
- Bottleneck: 1Γ1 reduction β 3Γ3 expansion with residual connections
- C2f: Cross-Stage Partial blocks with multiple Bottleneck layers
- SPPF: Spatial Pyramid Pooling Fast for multi-scale feature extraction
Loss Function Evolution
The initial MSE + BCE loss function suffered from underfitting. It was replaced with:
- CIoU Loss: Complete Intersection over Union, accounting for centroid distance and aspect ratio
- Distribution Focal Loss (DFL): Focusing on hard-to-classify examples with a Ξ³ parameter
Datasets
Six dataset configurations were tested:
- Trailer dataset: Trailer images only
- Sticker dataset: Sticker/barcode images only
- Combined dataset: Both merged
- Combined (no trailer subclasses): Removed Trailer_2, Trailer_3, Trailer_4
- Combined (no stickers): Removed sticker images
- Trailer (Trailer_1 + stickers only): Simplified classes
NVIDIA Jetson Platform
Hardware Journey
The project went through several hardware iterations:
- Jetson Nano 2GB: Hit End-of-Life status, boot failures after dependency installation, abandoned
- Jetson AGX Orin: Initial development platform, pre-installed OS
- Jetson Orin Nano 8GB: Final deployment target, reflashed with JetPack 6.x
Model Deployment Pipeline
PyTorch (.pth) β ONNX (.onnx) β TensorRT (.trt)
The conversion pipeline enables significant inference speedups on NVIDIA GPUs:
- PyTorch β ONNX: Export with
torch.onnx.export(), opset version 11 - ONNX β TensorRT: Parse and build optimized CUDA engine
- Inference: Real-time camera feed processing with PyCUDA memory management
Results
| Model | Size | Precision | Recall | mAP50 | mAP50-95 |
|---|---|---|---|---|---|
| YOLOv8 Combined (no stickers), m | Medium | 0.989 | 0.934 | 0.971 | 0.944 |
| YOLOv8 Combined, s | Small | 0.987 | 0.930 | 0.967 | 0.938 |
| YOLOv8 Combined (no trailer classes), n | Nano | 0.984 | 0.905 | 0.953 | 0.915 |
| YOLOv8 Trailer_1 + Stickers, n | Nano | 0.937 | 0.829 | 0.917 | 0.732 |
| Faster R-CNN (Sticker) | N/A | Loss: 0.1968, Inference: 0.031s/iter | |||
| Faster R-CNN (Trailer) | N/A | Loss: 0.2267, Inference: 0.042s/iter | |||
The YOLOv8 medium model trained on the combined dataset without sticker images achieved the best overall performance with 98.9% precision and 97.1% mAP50.
Key Challenges & Learnings
- Tensor shape alignment in custom YOLOv8, getting all model components to produce compatible tensor dimensions was the most difficult technical challenge
- Loss function implementation: transitioning from MSE/BCE to CIoU + DFL required careful mathematical implementation
- Jetson platform setup: multiple hardware iterations, boot failures, dependency conflicts, and JetPack version incompatibilities
- Custom vs. library trade-off: the from-scratch YOLOv8 implementation provided deep architectural understanding but the Ultralytics library delivered production-ready results
Context
This project was developed as a Bachelor's thesis at the University of Applied Sciences OsnabrΓΌck (Campus Lingen), Institute for Management and Technology, in collaboration with Krone Business Center GmbH as part of the TIDA5G research initiative for automated yard inventory management.