Coder Social home page Coder Social logo

human_action_recognition's Introduction

Human Action Recognition using Deep Learning (Demo Project)

Contributors of this project: Abdulkadir Yapıcı, Batuhan Meseci, Murat Acar, Riza Bocoglu

In this project, we developed human action recognition system using deep learning. You can check our final model's evaluation from video below.

Youtube Video

The dataset can be found here. We used three actions from dataset which are hand waving, boxing, movement. We also created our own data which is no movement dataset which includes mostly black images.

Code is seperated into three parts.

create_data.py: In this function, we create the training data from the original dataset.

  • toMH(): This function takes the filename, lines in sequences file which includes filename, the current person's number and file number as an argument. The first line where the assignment to video_src should be fixed. We manually assign the filename to handclapping_frames.

motion_history.py: In this function, we start the camera and capture frames using OpenCV. We define possible actions and load the model from args.model_dir. The main flow of the program:

  • Calculate the absoulute difference between current and previous frames using cv2.absdiff().
  • Convert the absolute difference between frames to grayscale frame/image using cv2.cvtColor().
  • Apply threshold to grayscale image using cv2.threshold().
  • Update the motion history using cv2.motempl.updateMotionHistory().
  • Normalize the motion history using np.clip().
  • Show motion history and raw frames on the screen using cv2.imshow().
  • For prediction, we resize the current frame to (120x120) and predict the frame using model.predict().
  • Stack 20 consecutive prediction.
  • Find the most frequent prediction and print as result using np.bincount() and np.argmax().
  • Clear the stack.

train_model.py: This is the main file which includes everything about training models. There are three functions in this file.

  • read_images: this function recursively looks into the subdirectories of img_dir argument. Read files using OpenCV and resize it(img_size:120x120) and then convert to grayscale image.
  • plot_data: this function plots randomly 20 images from dataset.
  • get_model: we define the neural network architecture in this function. Model can be seen here.

After downloading the dataset, how to run files:

  1. First of all, we should create the training dataset from the original data. For example, to create handclapping data: python create_data.py handclapping:

  2. After creating the dataset, we should train our model. To do that: python train_data.py images --> here images should be the output of create_data.py file. There are some additional parameters which are model_name: name of the model, epochs: number of epochs to train the model, val_split: validation split for training data and plot_data: if exists, plotting the randomly selected 20 image from the dataset.

  3. Evaluation of the trained model: python motion_history.py model_dir: here model_dir is trained model's file.

Architecture of the Model

human_action_recognition's People

Contributors

snnclsr avatar

Watchers

 avatar  avatar  avatar

human_action_recognition's Issues

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.