Deploying a Transformer-based Model in Microservices Architecture: An Approach for Real-Time Body Pose Classification
Authors: Bances P Enrique , Dalvi Vedant , Schneider Urs , Bauernhansl Thomas 
Published: February 2025

Real-time body pose classification is essential in preventing injuries caused by repetitive strain or poor ergonomics. In industrial environments, ensuring worker safety often requires monitoring the poses of multiple individuals performing different tasks. However, analysing the movements of many workers simultaneously presents computational challenges, potentially impacting accuracy and latency. In this context, microservices architecture offers significant advantages for enabling individual application functionalities to operate independently. Also, this architecture allows systems to scale efficiently in response to specific workload demands by adding CPU, memory, and storage resources, improving system performance and resource efficiency.This study evaluates the scalability of a real-time body pose classification system deployed using a microservices architecture, comparing it against a traditional monolithic approach. The system used a transformer-based model designed to monitor awkward body positions and identify constraints in joint movements. The methodology involves offline training on sequential data representing body joint angles, collected using an IMU sensor-based motion capture (MoCap) system. The system streams joint angles wirelessly from participants performing logistic tasks, such as lifting and carrying sandbags, in an industrial setting.Once trained, the classification model is deployed in real-time, processing streaming data for live body pose classification. Inference results from both architectures are stored in a time-series database for performance analysis. Scalability tests were conducted by deploying services for varying numbers of participants (one, three, five, and ten) in parallel across both architectural setups. Data throughput, latency, and resource utilisation (CPU and memory usage) were monitored during load testing.The results show that the microservices architecture outperforms the monolithic architecture in scalability. When scaled to accommodate multiple participants, it achieved higher data throughput, reduced latency by 18-48%, and decreased CPU usage by 18-44%. These findings validate the effectiveness of microservices architecture in enhancing the performance and scalability of real-time body pose classification systems.The method involves offline training of a transformer model on sequential data of body joint angles from participants performing a logistic task of lifting and carrying sandbags in an industrial environment. The data was collected from multiple participants using an IMU sensor-based motion capture (mocap) system that streams body joint angles wirelessly. Data was cleaned, labeled, and processed to train the transformer-based deep learning model. A data streaming pipeline from the mocap suit was set up, which streams the body joint angles in a Kafka topic in real-time. Once trained, the classification model is deployed online, receiving real-time streaming data for body pose classification. In the microservices-based application, the data obtained in the server is processed through a data processing microservice and later through an inference/classification service that predicts the real-time body pose for the logistic task. On the other hand, the data is processed, and inference is computed on the processed data in the same monolithic code. The inference results from both architecture-based applications are saved in a time-series database for performance evaluation.The scalability performance of the developed application was tested by deploying services for one, three, five, and ten participants in parallel under both architectures. The data throughput, latency, and resource utilization (CPU and memory usage) were monitored during the load testing. The results demonstrated that microservices architecture provides higher data throughput, reduces latency by 20%, and lowers CPU consumption by 40% compared to the monolithic architecture when scaled to multiple participants. The test results validated the scalability benefits of microservices architecture for a real-time body pose classification application.