This project implements a Masked Autoencoder (MAE) for learning representations from IMU (Inertial Measurement Unit) data for human gait analysis.
config.py: Configuration settings for the modeldataset.py: Dataset loading and preprocessingmae.py: Implementation of the Masked Autoencoder modeltrainer.py: Training utilitiestraining.py: Main training scriptutils.py: Helper functionsvisualize_output.py: Visualization tool for model input vs reconstructionevaluate_model.py: Evaluation metrics and performance analysisvisualize_masking.py: Visualization of the masking process
The project includes three visualization tools to help understand the model:
This tool allows you to visualize how well the model is reconstructing the original input data.
python visualize_output.py --checkpoint path/to/model/checkpoint.pth --data_path path/to/test/data --output_dir ./visualizationsOptional arguments:
--num_samples 5: Number of samples to visualize--channels 0 1 2: Which channels to plot (defaults to first 3)--device cuda: Device to run on ('cuda' or 'cpu')
This tool provides quantitative evaluation of the model's performance.
python evaluate_model.py --checkpoint path/to/model/checkpoint.pth --data_path path/to/test/data --output_dir ./evaluation_resultsOptional arguments:
--batch_size 32: Batch size for evaluation--num_samples 100: Limit number of samples to evaluate (None = use all)--device cuda: Device to run on ('cuda' or 'cpu')
This tool helps visualize the masking and reconstruction process to understand what parts of the input the model is focusing on.
python visualize_masking.py --checkpoint path/to/model/checkpoint.pth --data_path path/to/test/data --output_dir ./masking_visualizationsOptional arguments:
--num_samples 3: Number of samples to visualize--channels 0 1 2: Which channels to plot (defaults to first 3)--mask_ratio 0.75: Ratio of patches to mask--device cuda: Device to run on ('cuda' or 'cpu')
To train the model from scratch:
python training.pyIf you have a pre-trained model, you can evaluate it or visualize its outputs using the provided tools.
Example:
# Evaluate the model
python evaluate_model.py --checkpoint /path/to/checkpoint.pth --data_path /path/to/test/data
# Visualize reconstructions
python visualize_output.py --checkpoint /path/to/checkpoint.pth --data_path /path/to/test/dataThis project uses a Masked Autoencoder architecture for self-supervised representation learning from time-series IMU data. The model is trained by:
- Masking random parts of the input signal (default: 75% masked)
- Encoding the visible portions with a Transformer encoder
- Reconstructing the full signal with a Transformer decoder
- Training on the reconstruction loss
The learned representations can be used for various downstream tasks related to human gait analysis.