GithubHelp home page GithubHelp logo

realtime-semg's Introduction

MSc Project Real Time sEMG

Summary

Surface electromyography (sEMG) is a non-invasive measurements of the electrical activity in human muscles, which has a wide variety of uses in the clinical and rehabilitation domains. Gesture recognition is also an important application scenario for sEMG data. It plays an important role in prosthetic control and human-computer interaction. In this project, several different gesture recognition models based on deep learning approach were evaluated. The state-of-the-art deep learning method based on sEMG data mainly uses two-dimension convolutional neural networks (CNNs). Inspired by this, this project applied a three-dimensional CNN on sEMG dataset for gesture recognition problem. By utilizing both temporal and spatial changes, it can extract implicit information from segmented sEMG image sequence. Moreover, sEMG is a signal sequence data that is naturally suitable for recurrent neural networks (RNNs). This project also tried a novel RNNs model, stacked Long short-term memory (LSTM), applied to sEMG data. To validate the capabilities of the two models on sEMG, and also compare with the existing work, there are two sEMG dataset used in this project, CapgMyo and CSL-HDEMG. The accuracy of 8 gesture classification of the three-dimensional CNN and stacked LSTM model are 90.16% and 86.12% on CapgMyo dataset. In contrast, the accuracy of the existing two-dimensional CNN model reproduced in this project is 78.10%. And the gesture classification accuracy of three-dimensional CNN also reached 70.17% on CSL-HDEMG dataset.

Getting Started

Requirements

Config Environment

$ conda env update --file environment.yml
$ conda activate emg
$ mkdir data # the folder for training data
$ mkdir checkpoints # the folder for training log
$ mkdir tensorboard # the folder for tensorboard log

Quick Usage

Please download the data set first.

CapgMyo data is HERE. Put the data into the data/capg folder.

CSL-HDEMG data can download from HERE. Put the data into the data/csl folder.

Train model with CapgMyo data set

$ sudo chmod +x ./experiments/capg_train.sh
$ ./experiments/capg_train.sh

Train model with CSL-HDEMG data set

$ sudo chmod +x ./experiments/csl_train.sh
$ ./experiments/capg_train.sh

Directory

.
├── README.md
├── checkpoints
├── data
│   ├── capg
│   ├── capg-processed
│   ├── csl
│   └── csl-processed
├── emg
├── experiments
│   ├── capg_train.sh
│   ├── config.sh
│   ├── csl_train.sh
│   └── run
├── environment.yml
└── tensorboard

realtime-semg's People

Contributors

tenghuo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

windmill7790

realtime-semg's Issues

Model Selection

要根据validation score来选择hyperparameter,根据test score来选择hyperparameter就是在test set上过拟合

Floating point exception (core dump)

code crash during the training

Core was generated by `python -m emg.app --model cnn --gesture_num 8 --lr 0.01 --epoch 60 --train_batc'.

Program terminated with signal SIGFPE, Arithmetic exception.

#0  0x00007f27da86a45a in c10::cuda::CUDACachingAllocator::THCCachingAllocator::malloc(void**, unsigned long, CUstream_st*) () from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libc10_cuda.so
[Current thread is 1 (Thread 0x7f28240fb740 (LWP 4325))]
(gdb) bt
#0  0x00007f27da86a45a in c10::cuda::CUDACachingAllocator::THCCachingAllocator::malloc(void**, unsigned long, CUstream_st*) () from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libc10_cuda.so
#1  0x00007f27da86b347 in c10::cuda::CUDACachingAllocator::CudaCachingAllocator::allocate(unsigned long) const () from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libc10_cuda.so
#2  0x00007f27e6828706 in THCStorage_resize ()
   from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libcaffe2_gpu.so
#3  0x00007f27e683ee68 in THCTensor_resizeNd ()
   from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libcaffe2_gpu.so
#4  0x00007f27e683fcd8 in THCudaTensor_resize1d ()
   from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libcaffe2_gpu.so
#5  0x00007f27e778a500 in THNN_CudaClassNLLCriterion_updateOutput ()
   from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libcaffe2_gpu.so
#6  0x00007f27e67f557b in at::CUDAType::_thnn_nll_loss_forward(at::Tensor const&, at::Tensor const&, at::Tensor const&, long, long) const ()
   from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libcaffe2_gpu.so
#7  0x00007f27e2a344da in at::native::nll_loss_forward(at::Tensor const&, at::Tensor const&, at::Tensor const&, long, long) () from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libcaffe2.so
#8  0x00007f27e2dd35ac in at::TypeDefault::nll_loss_forward(at::Tensor const&, at::Tensor const&, at::Tensor const&, long, long) const ()
   from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libcaffe2.so
#9  0x00007f27db1329b9 in torch::autograd::VariableType::nll_loss_forward(at::Tensor const&, at::Tensor const&, at::Tensor const&, long, long) const ()
   from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libtorch.so.1
#10 0x00007f27e2a343aa in at::native::nll_loss(at::Tensor const&, at::Tensor const&, at::Tensor const&, long, long) () from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libcaffe2.so
#11 0x00007f27e2dd375c in at::TypeDefault::nll_loss(at::Tensor const&, at::Tensor const&, at::Tensor const&, long, long) const () from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libcaffe2.so
#12 0x00007f27daf1dc53 in torch::autograd::VariableType::nll_loss(at::Tensor const&, at::Tensor const&, at::Tensor const&, long, long) const ()
   from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libtorch.so.1
#13 0x00007f28111ee1ff in torch::autograd::THPVariable_nll_loss(_object*, _object*, _object*) ()
   from /home/teng/miniconda3/envs/py36/lib/python3.6/site-packages/torch/lib/libtorch_python.so
#14 0x000056308af36744 in _PyCFunction_FastCallDict ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/methodobject.c:231
#15 0x000056308afbd42c in call_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4851
#16 0x000056308afe238a in _PyEval_EvalFrameDefault ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
#17 0x000056308afb68e4 in _PyEval_EvalCodeWithName ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
#18 0x000056308afb7771 in fast_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4992
#19 0x000056308afbd505 in call_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
#20 0x000056308afe238a in _PyEval_EvalFrameDefault ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
#21 0x000056308afb68e4 in _PyEval_EvalCodeWithName ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
#22 0x000056308afb7771 in fast_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4992
#23 0x000056308afbd505 in call_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
#24 0x000056308afe238a in _PyEval_EvalFrameDefault ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
#25 0x000056308afb6bfe in _PyEval_EvalCodeWithName ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
#26 0x000056308afb7771 in fast_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4992
#27 0x000056308afbd505 in call_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
#28 0x000056308afe238a in _PyEval_EvalFrameDefault ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
#29 0x000056308afb753b in _PyFunction_FastCall (globals=<optimised out>, nargs=1, args=<optimised out>, 
    co=<optimised out>) at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4933
#30 fast_function () at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4968
#31 0x000056308afbd505 in call_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
#32 0x000056308afe238a in _PyEval_EvalFrameDefault ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
#33 0x000056308afb68e4 in _PyEval_EvalCodeWithName ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
#34 0x000056308afb7771 in fast_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4992
#35 0x000056308afbd505 in call_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
#36 0x000056308afe3147 in _PyEval_EvalFrameDefault ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3351
#37 0x000056308afb6bfe in _PyEval_EvalCodeWithName ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
#38 0x000056308afb7771 in fast_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4992
#39 0x000056308afbd505 in call_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
#40 0x000056308afe238a in _PyEval_EvalFrameDefault ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
#41 0x000056308afb753b in _PyFunction_FastCall (globals=<optimised out>, nargs=1, args=<optimised out>, 
    co=<optimised out>) at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4933
#42 fast_function () at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4968
#43 0x000056308afbd505 in call_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
#44 0x000056308afe238a in _PyEval_EvalFrameDefault ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
#45 0x000056308afb8289 in _PyEval_EvalCodeWithName (qualname=0x0, name=<optimised out>, closure=0x0, 
    kwdefs=0x0, defcount=0, defs=0x0, kwstep=2, kwcount=<optimised out>, kwargs=0x7f2823f608a8, 
    kwnames=0x7f2823f608a0, argcount=<optimised out>, args=0x7f2822325cd8, locals=0x0, 
    globals=<optimised out>, _co=0x7f2822500db0)
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
#46 PyEval_EvalCodeEx () at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4187
#47 0x000056308afb91a6 in function_call ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/funcobject.c:604
#48 0x000056308af3654e in PyObject_Call ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
#49 0x000056308afe3a6c in do_call_core (kwdict=0x7f28224dbb40, callargs=0x7f28240bb048, func=0x7f28223082f0)
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5120
#50 _PyEval_EvalFrameDefault () at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3404
#51 0x000056308afb68e4 in _PyEval_EvalCodeWithName ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
#52 0x000056308afb7e6a in _PyFunction_FastCallDict ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
#53 0x000056308af36b0f in _PyObject_FastCallDict ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
#54 0x000056308af3b6a3 in _PyObject_Call_Prepend ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
#55 0x000056308af3654e in PyObject_Call ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
#56 0x000056308afe3a6c in do_call_core (kwdict=0x7f2822302ee8, callargs=0x7f282409cd30, func=0x7f28240ae348)
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5120
#57 _PyEval_EvalFrameDefault () at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3404
#58 0x000056308afb753b in _PyFunction_FastCall (globals=<optimised out>, nargs=2, args=<optimised out>, 
    co=<optimised out>) at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4933
#59 fast_function () at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4968
#60 0x000056308afbd505 in call_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
#61 0x000056308afe238a in _PyEval_EvalFrameDefault ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
#62 0x000056308afb68e4 in _PyEval_EvalCodeWithName ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
#63 0x000056308afb7e6a in _PyFunction_FastCallDict ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
#64 0x000056308af36b0f in _PyObject_FastCallDict ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
#65 0x000056308af3b6a3 in _PyObject_Call_Prepend ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
#66 0x000056308af3654e in PyObject_Call ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
#67 0x000056308afe3a6c in do_call_core (kwdict=0x7f28224bb630, callargs=0x7f28240bb048, func=0x7f2822561148)
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5120
#68 _PyEval_EvalFrameDefault () at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3404
#69 0x000056308afb68e4 in _PyEval_EvalCodeWithName ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
#70 0x000056308afb7c4c in _PyFunction_FastCallDict ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
#71 0x000056308af36b0f in _PyObject_FastCallDict ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
#72 0x000056308af3b6a3 in _PyObject_Call_Prepend ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
#73 0x000056308af3654e in PyObject_Call ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
#74 0x000056308af90a91 in slot_tp_call ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/typeobject.c:6207
#75 0x000056308af3692b in _PyObject_FastCallDict ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2331
#76 0x000056308afbd57e in call_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4875
#77 0x000056308afe238a in _PyEval_EvalFrameDefault ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
#78 0x000056308afb8289 in _PyEval_EvalCodeWithName (qualname=0x0, name=<optimised out>, closure=0x0, 
    kwdefs=0x0, defcount=0, defs=0x0, kwstep=2, kwcount=<optimised out>, kwargs=0x0, kwnames=0x0, 
    argcount=0, args=0x0, locals=0x7f28240711f8, globals=0x7f28240711f8, _co=0x7f282252c030)
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
#79 PyEval_EvalCodeEx () at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4187
#80 0x000056308afb901c in PyEval_EvalCode (co=co@entry=0x7f282252c030, 
    globals=globals@entry=0x7f28240711f8, locals=locals@entry=0x7f28240711f8)
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:731
#81 0x000056308afdfd97 in builtin_exec_impl.isra.11 (locals=0x7f28240711f8, globals=0x7f28240711f8, 
    source=0x7f282252c030) at /tmp/build/80754af9/python_1546130271559/work/Python/bltinmodule.c:983
#82 builtin_exec () at /tmp/build/80754af9/python_1546130271559/work/Python/clinic/bltinmodule.c.h:283
#83 0x000056308af36681 in _PyCFunction_FastCallDict ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/methodobject.c:234
#84 0x000056308afbd42c in call_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4851
#85 0x000056308afe238a in _PyEval_EvalFrameDefault ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
#86 0x000056308afb68e4 in _PyEval_EvalCodeWithName ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
#87 0x000056308afb7771 in fast_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4992
#88 0x000056308afbd505 in call_function ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
#89 0x000056308afe238a in _PyEval_EvalFrameDefault ()
    at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
#90 0x000056308afb8289 in _PyEval_EvalCodeWithName (qualname=0x0, name=<optimised out>, closure=0x0, 
    kwdefs=0x0, defcount=1, defs=0x7f2822525060, kwstep=2, kwcount=<optimised out>, kwargs=0x0, 
    kwnames=0x0, argcount=<optimised out>, args=0x56308bd53c80, locals=0x0, globals=<optimised out>, 
    _co=0x7f2822517b70) at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
#91 PyEval_EvalCodeEx () at /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4187
#92 0x000056308afb9109 in function_call ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/funcobject.c:604
#93 0x000056308af3654e in PyObject_Call ()
    at /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
#94 0x000056308b034b07 in RunModule () at /tmp/build/80754af9/python_1546130271559/work/Modules/main.c:215
#95 0x000056308b03f1b6 in Py_Main () at /tmp/build/80754af9/python_1546130271559/work/Modules/main.c:752
#96 0x000056308af0802e in main () at /tmp/build/80754af9/python_1546130271559/work/Programs/python.c:69
#97 0x00007f2823902b97 in __libc_start_main (main=0x56308af07f40 <main>, argc=19, argv=0x7ffd1ac92a38, 
    init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7ffd1ac92a28)
    at ../csu/libc-start.c:310
#98 0x000056308afe8e0e in _start () at ../sysdeps/x86_64/elf/start.S:103

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.