A research framework for Human Activity Recognition (HAR) that studies accelerometer-gyroscope smartphone–smartwatch sensor fusion across diverse deep learning models. The code lives in Code/, with data preparation, supervised and self‑supervised training, and utilities to reproduce figures and results.
RobustHAR/
├── Code/
│ ├── Loaders/ # Dataset loaders (12 public HAR datasets)
│ ├── Preparers/ # Data preparation pipeline components
│ ├── Training/ # Supervised models (CNN, TCN, LSTM, Transformer, HART, …)
│ ├── Training_SSL/ # Self-supervised (CroSSL) training
│ ├── Models/ # Saved models and metadata
│ ├── final_data/ # Prepared SL datasets (npz)
│ ├── final_data_ssl/ # Prepared SSL datasets (npy)
│ ├── prepare_data.py # Main data prep entrypoint/config
│ ├── paper_visualizations_barchart.py
│ ├── paper_label_split_table.py
│ └── requirements.txt
├── Other/ # Supplemental analysis (Data clipping plots, Label distribution analysis,...)
└── README.md # You are here
- Single-file configuration: All stages are controlled in
Code/prepare_data.py(loaders, resampling, fusion, label set, ILP split, scaling, windowing, SSL toggle). Change one place; everything else adapts. - Minimal rebuilds: The pipeline skips completed stages; use
generate_data()to force a full rebuild when you change configuration. - Easy to repurpose: Works for related multivariate time-series tasks. Add a new loader in
Code/Loaders/and register it inPHONE_LOADERS,WATCH_LOADERS, orBOTH_LOADERSor remove existing ones to adapt to your usecase. - Programmatic overrides: You can override config values from Python without editing logical code.
import prepare_data as cfg
cfg.MERGE = False # e.g., train on single-device data only
cfg.FREQUENCY = 50 # resample to 50 Hz
cfg.WINDOW_SIZE = 128 # longer temporal context
data = cfg.generate_data() # rebuild with the new configurationThis design makes the data layer portable across projects: tweak the prepare_data.py config to produce new datasets (SL and SSL) without touching training code.
- Create environment and install dependencies
# from repo root
cd Code
python -m venv .venv && source .venv/bin/activate # or: conda create -n robusthar python=3.10
pip install --upgrade pip
pip install -r requirements.txt- Prepare data (runs the full 7‑stage pipeline on first use; writes to
final_data/andfinal_data_ssl/)
# from RobustHAR/Code
python prepare_data.pyAlternatively (as a library):
from prepare_data import get_data
all_data = get_data() # returns a dict with loaded arrays; creates data if missing- Train models
- Supervised (examples):
# Random search (Phase 1)
python Training/CNN/CNN_FULL_random.py
python Training/HART/HART_FULL_random.py
# Grid search (Phase 2)
python Training/CNN/CNN_all_grid.py
python Training/HART/HART_all_grid.py- Self‑supervised (CroSSL):
python Training_SSL/CroSSL/CNNCroSSL_FULL_random.py
python Training_SSL/CroSSL/CNNCroSSL_all_grid.pyNotes:
- Most models expect a (Multi-)GPU environment (except MLP run on CPU). See
Code/Training/ReadMe.mdfor details. - Training scripts will trigger data preparation (according to the current config file) automatically if needed.
# from RobustHAR/Code
python paper_visualizations_barchart.py # Generates benchmark bar charts
python paper_label_split_table.py # Generates label split table (and Paper_Figures_generated)- Not enough memory to process all data
- Not providing the correct environment (CPU vs. GPU) for model training
- Data Preparation Pipeline config file
prepare_data.pydoes not align with the input of the DL models when trying to train of non-defaultprepare_data.py.
- Data pipeline and configuration:
Code/Preparers/Readme.md - Supervised training framework (models, search strategy, outputs):
Code/Training/ReadMe.md - SSL training (CroSSL):
Code/Training_SSL/ReadMe.md - High‑level project overview:
Code/ReadMe.md
- Prepared datasets:
Code/final_data/(*_train.npz,*_val.npz,*_test.npz) andCode/final_data_ssl/(*.npy) - Trained models and artifacts:
Code/Models/{all|phone|watch}/with.keras/.pt,*.txtmetadata, and loss curves (*.png)
If you use this framework, please cite:
Zubairov, N., Milling, M., Schuller, B., Fleisch, E., & Langer, P. (2025). Enhancing Wearable Human Activity Recognition through Smartphone and Smartwatch Sensor Fusion. Under review.
@article{Zubairov2025HARFusion,
title = {Enhancing Wearable Human Activity Recognition through Smartphone and Smartwatch Sensor Fusion},
author = {Zubairov, Nikita and Milling, Manuel and Schuller, Bj{"o}rn and Fleisch, Elgar and Langer, Patrick},
year = {2025},
note = {Under review},
url = {https://github.com/ADAMMA-CDHI-ETH-Zurich/RobustHAR}
}