Skip to content

Open-EXG/handDistill

Repository files navigation

Knowledge Distillation for sEMG-Based Gesture Recognition

This repository contains the official implementation of the paper:

"Knowledge Distillation for sEMG-Based Gesture Recognition: Enhancing Wearable HMI Systems with Lightweight Models"

Preprocessed Data

The preprocessed dataset used in this study is available at: https://zenodo.org/records/20150061

For detailed dataset information and experimental setup, please refer to the original paper.

Overview

This project implements a knowledge distillation framework that transfers cross-subject knowledge from large teacher models to lightweight student models for surface electromyography (sEMG)-based hand gesture recognition.

Project Structure

├── models.py                  # All model architectures (Teacher & Student)
├── datasets.py                # Dataset classes and data utilities
├── utils.py                   # Shared training/evaluation utilities
├── handDataset.py             # Raw data loading and augmentation functions
│
├── teacher_train.py           # Stage 1: Teacher pre-training (5-fold CV)
├── teacher_finetune.py        # Stage 2: Teacher fine-tuning (per-subject)
├── distill.py                 # Stage 3: Knowledge distillation
├── test_teacher.py            # Teacher model evaluation
├── test_student.py            # Student model evaluation
│
├── baseline.py                # Baseline methods (CNN, LSTM, CNN-LSTM, GRU)
├── preload_data.py            # Data preprocessing and caching tool
├── drawresults_flops.py       # Result visualization (accuracy vs. FLOPs)
├── draw_hypothesis_heatmap.py # Hypothesis testing heatmap
├── teacher_final_checkmodel.py# Model architecture verification tool
├── baseline_cnn_lstm.py       # CNN-LSTM baseline variant
│
├── P3D/                       # P3D model implementation
└── figure_article/            # Generated figures for the paper

Requirements

  • Python 3.8+
  • PyTorch
  • torchvision
  • scikit-learn
  • scipy
  • matplotlib
  • tqdm
  • torchstat
  • tensorboard

Usage

Stage 1: Teacher Pre-training

Train teacher models with 5-fold cross-validation:

python teacher_train.py --device 1 --fold 1 --model densenet121 --batch_size 300 --num_epochs 500

Stage 2: Teacher Fine-tuning

Fine-tune teacher models per subject:

python teacher_finetune.py --device 1 --fold 1 --model densenet121 --batch_size 125 --num_epochs 30

Stage 3: Knowledge Distillation

Distill teacher knowledge to lightweight student models:

python distill.py --device 0 --fold 1 --teacher_model densenet121 --student_model cnn --alpha 0 --temp 20 --num_epochs 200

Evaluation

# Evaluate teacher model
python test_teacher.py --device 0 --fold 1 --teacher_model densenet121

# Evaluate student model
python test_student.py --device 0 --fold 1 --teacher_model densenet121 --student_model cnn

Available Models

Teacher Models

Model Class Name Parameters
DenseNet-34 CustomDNN_34 5.9M
DenseNet-121 CustomDNN_slice_test 13.8M
DenseNet-161 CustomDNN_161 35.7M
DenseNet-201 CustomDNN_201 26.7M
VGG-small VGGbn_small 71.4M
VGG-11 VGGbn_11 129.8M
VGG-16 VGGbn_16 135.3M
InceptionXS InceptionV3_xs 10.7M
InceptionS InceptionV3_s 16.1M
InceptionV3 InceptionV3 24.2M

Student Models

Model Class Name Parameters
CNN CustomCNN_sml3 2.0M
LSTM CustomLSTM 2.3M

Citation

If you find this work useful, please cite:

@article{kd_semg_gesture,
  title={Knowledge Distillation for sEMG-Based Gesture Recognition: Enhancing Wearable HMI Systems with Lightweight Models},
  author={},
  journal={},
  year={2025}
}

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages