All Projects → TwentyBN → Sense

TwentyBN / Sense

Licence: mit
Enhance your application with the ability to see and interact with humans using any RGB camera.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Sense

Pyod
A Python Toolbox for Scalable Outlier Detection (Anomaly Detection)
Stars: ✭ 5,083 (+873.75%)
Mutual labels:  neural-networks
Diffeqflux.jl
Universal neural differential equations with O(1) backprop, GPUs, and stiff+non-stiff DE solvers, demonstrating scientific machine learning (SciML) and physics-informed machine learning methods
Stars: ✭ 473 (-9.39%)
Mutual labels:  neural-networks
Geomstats
Computations and statistics on manifolds with geometric structures.
Stars: ✭ 498 (-4.6%)
Mutual labels:  neural-networks
Onnxruntime
ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
Stars: ✭ 5,910 (+1032.18%)
Mutual labels:  neural-networks
Augmentor
Image augmentation library in Python for machine learning.
Stars: ✭ 4,594 (+780.08%)
Mutual labels:  neural-networks
Deep Learning Specialization Coursera
Deep Learning Specialization by Andrew Ng on Coursera.
Stars: ✭ 483 (-7.47%)
Mutual labels:  neural-networks
Spacy
💫 Industrial-strength Natural Language Processing (NLP) in Python
Stars: ✭ 21,978 (+4110.34%)
Mutual labels:  neural-networks
Machine Learning Articles
Monthly Series - Top 10 Machine Learning Articles
Stars: ✭ 516 (-1.15%)
Mutual labels:  neural-networks
Introtodeeplearning
Lab Materials for MIT 6.S191: Introduction to Deep Learning
Stars: ✭ 4,955 (+849.23%)
Mutual labels:  neural-networks
Chemprop
Message Passing Neural Networks for Molecule Property Prediction
Stars: ✭ 501 (-4.02%)
Mutual labels:  neural-networks
Seq2seqchatbots
A wrapper around tensor2tensor to flexibly train, interact, and generate data for neural chatbots.
Stars: ✭ 466 (-10.73%)
Mutual labels:  neural-networks
Deeplearning.ai Natural Language Processing Specialization
This repository contains my full work and notes on Coursera's NLP Specialization (Natural Language Processing) taught by the instructor Younes Bensouda Mourri and Łukasz Kaiser offered by deeplearning.ai
Stars: ✭ 473 (-9.39%)
Mutual labels:  neural-networks
Learn Data Science For Free
This repositary is a combination of different resources lying scattered all over the internet. The reason for making such an repositary is to combine all the valuable resources in a sequential manner, so that it helps every beginners who are in a search of free and structured learning resource for Data Science. For Constant Updates Follow me in …
Stars: ✭ 4,757 (+811.3%)
Mutual labels:  neural-networks
Dn2a
DN2A - Digital Neural Networks Architecture
Stars: ✭ 462 (-11.49%)
Mutual labels:  neural-networks
Edward
A probabilistic programming language in TensorFlow. Deep generative models, variational inference.
Stars: ✭ 4,674 (+795.4%)
Mutual labels:  neural-networks
Pytorch Tutorial
PyTorch Tutorial for Deep Learning Researchers
Stars: ✭ 22,442 (+4199.23%)
Mutual labels:  neural-networks
Bayesian Analysis Recipes
A collection of Bayesian data analysis recipes using PyMC3
Stars: ✭ 479 (-8.24%)
Mutual labels:  neural-networks
Speech Denoising Wavenet
A neural network for end-to-end speech denoising
Stars: ✭ 516 (-1.15%)
Mutual labels:  neural-networks
Dissecting Reinforcement Learning
Python code, PDFs and resources for the series of posts on Reinforcement Learning which I published on my personal blog
Stars: ✭ 512 (-1.92%)
Mutual labels:  neural-networks
Ofxdarknet
darknet neural network addon for openFrameworks
Stars: ✭ 493 (-5.56%)
Mutual labels:  neural-networks

State-of-the-art Real-time Action Recognition


WebsiteBlogpostGetting StartedBuild Your Own ClassifieriOS DeploymentDatasetsSDK License

Documentation GitHub GitHub release Contributor Covenant


senseis an inference engine to serve powerful neural networks for action recognition, with a low computational footprint. In this repository, we provide:

  • Two models out-of-the-box pre-trained on millions of videos of humans performing actions in front of, and interacting with, a camera. Both neural networks are small, efficient, and run smoothly in real time on a CPU.
  • Demo applications showcasing the potential of our models: gesture recognition, fitness activity tracking, live calorie estimation.
  • A pipeline to record and annotate your own video dataset and train a custom classifier on top of our models with an easy-to-use script to fine-tune our weights.
Gesture Recognition

(full video can be found here)

Fitness Activity Tracker and Calorie Estimation

(full video can be found here)


Requirements and Installation

The following steps are confirmed to work on Linux (Ubuntu 18.04 LTS and 20.04 LTS) and macOS (Catalina 10.15.7).

Step 1: Clone the repository

To begin, clone this repository to a local directory of your choice:

git clone https://github.com/TwentyBN/sense.git
cd sense

Step 2: Install Dependencies

We recommended creating a new virtual environment to install our dependencies using conda or virtualenv. The following instructions will help create a conda environment.

conda create -y -n sense python=3.6
conda activate sense

Install Python dependencies:

pip install -r requirements.txt

Note: pip install -r requirements.txt only installs the CPU-only version of PyTorch. To run inference on your GPU, another version of PyTorch should be installed (e.g. conda install pytorch torchvision cudatoolkit=10.2 -c pytorch). See all available install commands here.

Step 3: Download the SenseKit Weights

Pre-trained weights can be downloaded from here, subject to separate terms. Follow the instructions to create an account, agree to evaluation license and download the weights. Once downloaded, unzip the folder and move the folder named backbone into sense/resources. In the end, your resources folder structure should look like this:

resources
├── backbone
│   ├── strided_inflated_efficientnet.ckpt
│   └── strided_inflated_mobilenet.ckpt
├── fitness_activity_recognition
│   └── ...
├── gesture_recognition
│   └── ...
└── ...

Note: The remaining folders in resources/ will already have the necessary files -- only resources/backbone needs to be downloaded separately.


Getting Started

To get started, try out the demos we've provided. Inside the sense/examples directory, you will find 3 Python scripts, run_gesture_recognition.py, run_fitness_tracker.py, and run_calorie_estimation.py. Launching each demo is as simple as running the script in terminal as described below.

Demo 1: Gesture Recognition

examples/run_gesture_recognition.py applies our pre-trained models to hand gesture recognition. 30 gestures are supported (see full list here).

Usage:

PYTHONPATH=./ python examples/run_gesture_recognition.py

Demo 2: Fitness Activity Tracking

examples/run_fitness_tracker.py applies our pre-trained models to real-time fitness activity recognition and calorie estimation. In total, 80 different fitness exercises are recognized (see full list here).

Usage:

PYTHONPATH=./ python examples/run_fitness_tracker.py --weight=65 --age=30 --height=170 --gender=female

Weight, age, height should be respectively given in kilograms, years and centimeters. If not provided, default values will be used.

Some additional arguments can be used to change the streaming source:

  --camera_id=CAMERA_ID           ID of the camera to stream from
  --path_in=FILENAME              Video file to stream from. This assumes that the video was encoded at 16 fps.

It is also possible to save the display window to a video file using:

  --path_out=FILENAME             Video file to stream to

For the best performance, the following is recommended:

  • Place your camera on the floor, angled upwards with a small portion of the floor visible
  • Ensure your body is fully visible (head-to-toe)
  • Try to be in a simple environment (with a clean background)

Demo 3: Calorie Estimation

In order to estimate burned calories, we trained a neural net to convert activity features to the corresponding MET value. We then post-process these MET values (see correction and aggregation steps performed here) and convert them to calories using the user's weight.

If you're only interested in the calorie estimation part, you might want to use examples/run_calorie_estimation.py which has a slightly more detailed display (see video here which compares two videos produced by that script).

Usage:

PYTHONPATH=./ python examples/run_calorie_estimation.py --weight=65 --age=30 --height=170 --gender=female

The estimated calorie estimates are roughly in the range produced by wearable devices, though they have not been verified in terms of accuracy. From our experiments, our estimates correlate well with the workout intensity (intense workouts burn more calories) so, regardless of the absolute accuracy, it should be fair to use this metric to compare one workout to another.


Build Your Own Classifier with SenseStudio

This section will describe how you can use our SenseStudio tool to build your own custom classifier on top of our models. Our models will serve as a powerful feature extractor that will reduce the amount of data you need to build your project.

Step 1: Project Setup

First, run the tools/sense_studio/sense_studio.py script and open http://127.0.0.1:5000/ in your browser. There you can set up a new project in a location of your choice and specify the classes that you want to collect.

The tool will prepare the following file structure for your project:

/path/to/your/dataset/
├── videos_train
│   ├── class1
│   ├── class2
│   └── ...
├── videos_valid
│   ├── class1
│   ├── class2
│   └── ...
└── project_config.json
  • Two top-level folders: one for the training data, one for the validation data.
  • One sub-folder for each class that you specify.

Step 2: Data Collection

You can record videos for each class right in your browser by pressing the "Record" button. Make sure that you have ffmpeg installed for that.

Otherwise, you can also just move existing videos into the corresponding project folders. Those should have a framerate of 16 fps or higher.

In the end you should have at least one video per class and train/valid split, but preferably more. In some cases, as few as 2-5 videos per class have been enough to achieve excellent performance with our models!

Step 3: Training

Once your data is prepared, run this command to train a customized classifier on top of one of our features extractor:

PYTHONPATH=./ python tools/train_classifier.py --path_in=/path/to/your/dataset/ [--use_gpu] [--num_layers_to_finetune=9]

Step 4: Running your model

The training script should produce a checkpoint file called classifier.checkpoint at the root of the dataset folder. You can now run it live using the following script:

PYTHONPATH=./ python tools/run_custom_classifier.py --custom_classifier=/path/to/your/dataset/ [--use_gpu]

Advanced Options

You can further improve your model's performance by training on top of temporally annotated data; individually tagged frames that identify the event locally in the video versus treating every frame with the same label. For instructions on how to prepare your data with temporal annotations, refer to this page.

After preparing your dataset with our temporal annotations tool, pass --temporal_training as an additional flag to the train_classifier.py script.


iOS Deployment

If you're interested in mobile app development and want to run our models on iOS devices, please check out sense-iOS for step by step instructions on how to get our gesture demo to run on an iOS device. One of the steps involves converting our Pytorch models to the TensorFlow Lite format.

Conversion to TensorFlow Lite

Our models can be converted to TensorFlow Lite using the following script:

python tools/conversion/convert_to_tflite.py --backbone_name=StridedInflatedEfficientNet --backbone_version=pro --classifier=gesture_recognition --output_name=model

If you want to convert a custom classifier, set the classifier name to "custom_classifier", and provide the path to the dataset directory used to train the classifier using the "--path_in" argument.

python tools/conversion/convert_to_tflite.py --classifier=custom_classifier --path_in=/path/to/your/checkpoint/ --output_name=model

Citation

We now have a blogpost you can cite:

@misc{sense2020blogpost,
    author = {Guillaume Berger and Antoine Mercier and Florian Letsch and Cornelius Boehm and 
              Sunny Panchal and Nahua Kang and Mark Todorovich and Ingo Bax and Roland Memisevic},
    title = {Towards situated visual AI via end-to-end learning on video clips},
    howpublished = {\url{https://medium.com/twentybn/towards-situated-visual-ai-via-end-to-end-learning-on-video-clips-2832bd9d519f}},
    note = {online; accessed 23 October 2020},
    year=2020,
}

License

The code is copyright (c) 2020 Twenty Billion Neurons GmbH under an MIT Licence. See the file LICENSE for details. Note that this license only covers the source code of this repo. Pretrained weights come with a separate license available here.

The code makes use of these sounds from freesound:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].