Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Embedded Activity Recognition

Python TensorFlow Keras TensorFlow Lite scikit-learn NumPy Jupyter Notebook Raspberry Pi Edge AI Time Series GitHub Markdown

An embedded machine learning project for real-time human activity recognition and fall-detection experimentation on a Raspberry Pi. This project focuses on building, optimizing, converting, and deploying neural network models for edge inference under real-world embedded constraints.

The project demonstrates an end-to-end embedded AI workflow: sensor data collection, preprocessing, model training, architecture tuning, TensorFlow Lite conversion, Raspberry Pi deployment, and evaluation of accuracy, model size, and inference performance.


Overview

Embedded machine learning systems must balance accuracy, latency, memory usage, and deployability. This project explores that tradeoff by developing neural network models for activity recognition and deploying optimized TensorFlow Lite models to a Raspberry Pi.

The work was developed across multiple stages:

  1. Data acquisition and sample-rate measurement
  2. PC-based model training and testing
  3. Raspberry Pi model deployment
  4. Neural network optimization
  5. TensorFlow Lite conversion and inference testing

The project shows how machine learning models can move beyond notebook-based training and into practical edge-computing environments.


Project Goals

  • Collect and prepare activity-recognition sensor data
  • Train neural network models for activity and fall detection
  • Improve baseline model accuracy through preprocessing and architecture changes
  • Convert trained models to TensorFlow Lite for embedded deployment
  • Run inference on a Raspberry Pi
  • Compare optimized and non-optimized model behavior
  • Evaluate tradeoffs between model accuracy, model size, and inference time
  • Build experience with real-world embedded AI workflows

Technical Areas

Area Description
Embedded Machine Learning Deploying trained models on Raspberry Pi hardware
Activity Recognition Classifying motion-based activity patterns from sensor data
Data Acquisition Collecting sensor samples and measuring sample rate
Preprocessing Scaling and preparing data for neural network training
Neural Networks Training and tuning models using TensorFlow/Keras
Conv1D Modeling Using one-dimensional convolutional layers for time-series classification
TensorFlow Lite Converting trained models for lightweight edge inference
Edge Deployment Running inference scripts directly on Raspberry Pi
Performance Tradeoffs Balancing accuracy, latency, model size, and responsiveness

Repository Structure

embedded-activity-recognition/
│
├── Week 10/
│   ├── Lab10_final.docx
│   ├── data_acquire3.py
│   └── measure_sampleRate.py
│
├── Week 11/
│   ├── Data/
│   ├── OnPC/
│   │   └── fall_detect_v1.ipynb
│   ├── OnPi/
│   │   ├── model.tflite
│   │   ├── predict_cnn_piLite.py
│   │   ├── predict_tflite.py
│   │   └── windowNN_model.tflite
│   └── Week 11_Pre-Lab.docx
│
├── Week 12/
│   ├── NN_1NP/
│   │   ├── fall_detect_nn_1np.ipynb
│   │   ├── nn_model_raw_1np.tflite
│   │   └── predict_tflite_nn1np.py
│   ├── Pre-lab/
│   └── Week 12_Pre-Lab.docx
│
├── Week 13/
│   ├── ML_Model/
│   │   ├── Test 1/
│   │   ├── Test 2/
│   │   └── Test 3/
│   └── Pre-Lab.docx
│
└── README.md

Development Progression

Sensor Data Collection
        │
        ▼
Sample Rate Measurement
        │
        ▼
Data Preprocessing
        │
        ▼
Neural Network Training
        │
        ▼
Model Optimization
        │
        ▼
TensorFlow Lite Conversion
        │
        ▼
Raspberry Pi Deployment
        │
        ▼
Edge Inference Testing

Project Stages

Week 10 — Data Acquisition and Sampling

The first stage focused on collecting sensor data and understanding the sampling behavior of the embedded system.

Key Work

  • Collected sensor data for activity-recognition experiments
  • Measured sample rate behavior
  • Established the data collection pipeline for later model training
  • Built scripts for acquiring and analyzing motion data

Files

data_acquire3.py
measure_sampleRate.py
Lab10_final.docx

Skills Demonstrated

  • Sensor data acquisition
  • Python scripting
  • Sampling-rate measurement
  • Embedded data collection
  • Experimental setup and documentation

Week 11 — Initial Model Training and Raspberry Pi Deployment

The second stage focused on training an initial neural network model on a PC and deploying TensorFlow Lite models to the Raspberry Pi.

Key Work

  • Trained an initial fall/activity detection model on a PC
  • Converted trained models to TensorFlow Lite format
  • Deployed .tflite models to Raspberry Pi
  • Created prediction scripts for running inference on embedded hardware
  • Compared PC-side development with Pi-side deployment

Important Files

Week 11/OnPC/fall_detect_v1.ipynb
Week 11/OnPi/model.tflite
Week 11/OnPi/windowNN_model.tflite
Week 11/OnPi/predict_tflite.py
Week 11/OnPi/predict_cnn_piLite.py

Skills Demonstrated

  • TensorFlow/Keras model training
  • TensorFlow Lite conversion
  • Raspberry Pi deployment
  • Embedded inference scripting
  • PC-to-edge model workflow

Week 12 — Neural Network Optimization

The third stage focused on improving model performance and testing optimized neural network designs.

Key Work

  • Developed an improved neural network model
  • Used preprocessing to improve model stability
  • Tested optimized model behavior
  • Converted the improved model to TensorFlow Lite
  • Created a dedicated TFLite prediction script for the optimized model

Important Files

Week 12/NN_1NP/fall_detect_nn_1np.ipynb
Week 12/NN_1NP/nn_model_raw_1np.tflite
Week 12/NN_1NP/predict_tflite_nn1np.py

Skills Demonstrated

  • Neural network architecture tuning
  • Model preprocessing
  • TensorFlow Lite deployment
  • Embedded model evaluation
  • Activity-recognition model optimization

Week 13 — Model Testing and Evaluation

The final stage organized multiple model tests and evaluation attempts to compare behavior across different configurations.

Key Work

  • Organized model experiments into multiple test folders
  • Compared different model configurations
  • Evaluated model behavior across repeated trials
  • Continued improving edge-inference readiness

Files

Week 13/ML_Model/Test 1/
Week 13/ML_Model/Test 2/
Week 13/ML_Model/Test 3/

Skills Demonstrated

  • Model experiment organization
  • Repeated testing
  • Iterative model development
  • Embedded ML evaluation
  • Performance comparison

Model Optimization

The project improved the embedded activity-recognition model through several changes.

Key Improvements

  • Applied standard scaling to reduce noise and normalize input features
  • Increased training data usage from 60% to 80%
  • Added additional Conv1D layers for time-series feature extraction
  • Added MaxPooling1D layers to reduce feature dimensionality
  • Increased dropout from 0.2 to 0.3 to reduce overfitting
  • Increased training epochs from 15 to 50
  • Compared optimized and non-optimized TensorFlow Lite models

Machine Learning Pipeline

Raw Sensor Data
      │
      ▼
Data Cleaning and Formatting
      │
      ▼
Standard Scaling
      │
      ▼
Train/Test Split
      │
      ▼
Neural Network Training
      │
      ▼
Model Evaluation
      │
      ▼
TensorFlow Lite Conversion
      │
      ▼
Raspberry Pi Inference

Edge Deployment Pipeline

Trained Keras Model
      │
      ▼
TensorFlow Lite Converter
      │
      ▼
.tflite Model File
      │
      ▼
Raspberry Pi
      │
      ▼
Prediction Script
      │
      ▼
Real-Time Activity Classification

Results

The project improved the baseline model from approximately 0.80 accuracy to stronger optimized performance through preprocessing, model architecture changes, and training adjustments.

The final workflow produced TensorFlow Lite models that could be deployed and tested on Raspberry Pi hardware.

Main Outcomes

  • Built a working embedded machine learning pipeline
  • Trained neural network models for activity/fall detection
  • Converted models to TensorFlow Lite
  • Ran prediction scripts on Raspberry Pi
  • Improved classification performance through model tuning
  • Evaluated accuracy versus embedded deployment constraints

Tools and Technologies

Languages

  • Python

Machine Learning

  • TensorFlow
  • Keras
  • TensorFlow Lite
  • scikit-learn
  • NumPy
  • Jupyter Notebook

Hardware

  • Raspberry Pi
  • Motion/activity sensor data pipeline

Concepts

  • Embedded machine learning
  • Edge AI
  • Activity recognition
  • Fall detection
  • Time-series classification
  • Conv1D neural networks
  • Model optimization
  • TFLite deployment
  • Real-time inference

Skills Demonstrated

  • Embedded AI development
  • Raspberry Pi deployment
  • Sensor data acquisition
  • Sample-rate measurement
  • Machine learning preprocessing
  • Neural network training
  • Conv1D architecture tuning
  • TensorFlow Lite model conversion
  • Edge inference scripting
  • Activity-recognition modeling
  • Fall-detection experimentation
  • Model size and inference tradeoff analysis
  • End-to-end ML deployment workflow

Future Improvements

  • Add dataset documentation and label descriptions
  • Include plots for training and validation accuracy/loss
  • Add confusion matrix, precision, recall, and F1-score evaluation
  • Benchmark Raspberry Pi inference latency more systematically
  • Compare quantized and non-quantized TFLite models
  • Add a demo video or sample terminal output
  • Reorganize weekly folders into cleaner portfolio-style project folders
  • Add a requirements file for easier environment setup

Why This Project Matters

This project sits at the intersection of machine learning, embedded systems, and real-world deployment. It shows more than just model training; it shows the process of preparing a model for practical use on resource-constrained hardware.

The project is relevant to edge AI, wearable sensing, healthcare technology, activity monitoring, human-centered intelligent systems, and embedded machine learning applications.


Author

Jaiden Medina
Computer Engineering @ Indiana University
Accelerated M.S. in Intelligent Systems Engineering

About

Embedded machine learning project for real-time activity recognition and TensorFlow Lite inference on Raspberry Pi.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages