Recognising human actions in uploaded videos and live webcam feeds with ConvLSTM and a Kinetics-400 ResNet
Main Project (Phase 2) ยท Dept. of Information Science & Engineering ยท Bahubali College of Engineering, Shravanabelagola (VTU) ยท 2024-25
Build a Human Action Recognition (HAR) system that accurately detects and classifies human activities in real-world video, for use in healthcare monitoring, security and surveillance, sports analytics, robotics and smart homes.
- Develop an accurate HAR system using computer vision and deep learning
- Work reliably in diverse conditions (lighting, occlusion, camera angle)
- Minimise false positives for dependable predictions
| Model 1: ConvLSTM web app | Model 2: Real-time recognition | |
|---|---|---|
| Input | Uploaded video clip | Webcam or video stream |
| Network | ConvLSTM2D (trained from scratch) | ResNet-34 3D CNN pre-trained on Kinetics-400 (ONNX) |
| Classes | Basketball, Biking, Diving, Horse Riding | 400 Kinetics actions |
| Interface | Django web page | OpenCV window with live label |
| Code | recognition/, training/ |
realtime/ |
flowchart TD
A[User uploads video] --> B["upload_video(request)<br/>Django view"]
B --> C["extract_frames()<br/>20 evenly spaced frames, 64ร64, normalised"]
C --> D["adjust_frames()<br/>pad to exactly 20 frames"]
D --> E["ConvLSTM model.predict()"]
E --> F[Predicted action + confidence per class]
F --> G[result.html]
B -. video deleted after prediction .-> H[(temp storage)]
flowchart LR
A[Webcam / video] --> B[capture_and_store_frame<br/>deque of 16 frames]
B --> C[preprocess_frames<br/>blob 112ร112]
C --> D[ResNet-34 Kinetics<br/>OpenCV DNN]
D --> E[stabilize_prediction<br/>majority vote]
E --> F[display_label_on_frame]
- Dataset collection: UCF50 videos (Model 1), Kinetics-400 pre-trained weights (Model 2)
- Preprocessing: frame extraction, resizing, normalisation
- Feature learning: ConvLSTM layers learn spatial features (convolutions) and temporal patterns (LSTM) together
- Training & evaluation: 75/25 train-test split, early stopping
- Recognition: prediction on new clips or live frames
Input (20 frames ร 64 ร 64 ร 3)
โ ConvLSTM2D(4) โ MaxPool3D โ Dropout
โ ConvLSTM2D(8) โ MaxPool3D โ Dropout
โ ConvLSTM2D(14) โ MaxPool3D โ Dropout
โ ConvLSTM2D(16) โ MaxPool3D
โ Flatten โ Dense(4, softmax)
Human-Action-Recognition-using-Deep-Learning/
โโโ har_web/ # Django project settings and URLs
โโโ recognition/ # Django app (Model 1)
โ โโโ predictor.py # extract_frames, adjust_frames, predict_activity
โ โโโ views.py # upload_video view
โ โโโ templates/recognition/
โโโ training/
โ โโโ train_convlstm.py # Train ConvLSTM on UCF50
โโโ realtime/
โ โโโ realtime_har.py # Model 2: live Kinetics-400 recognition
โโโ models/ # Trained / downloaded model files (not committed)
โโโ manage.py
โโโ requirements.txt
git clone https://github.com/Gaganajain/Human-Action-Recognition-using-Deep-Learning.git
cd Human-Action-Recognition-using-Deep-Learning
python -m venv venv
venv\Scripts\activate # macOS/Linux: source venv/bin/activate
pip install -r requirements.txt-
Download UCF50 and extract it to
./UCF50. -
Train (saves
models/convlstm_model.h5andmodels/training_curves.png):python training/train_convlstm.py --dataset UCF50 --epochs 50
-
Start the web app and open http://127.0.0.1:8000:
python manage.py runserver
-
Put these two files in
models/:resnet-34_kinetics.onnx: ResNet-34 Kinetics model used by OpenCV's action recognition sample (converted from kenshohara/video-classification-3d-cnn-pytorch)action_recognition_kinetics.txt: the 400 Kinetics class names, one per line
-
Run:
python realtime/realtime_har.py # webcam python realtime/realtime_har.py --input clip.mp4 # video file
Press Q or Esc to quit.
| Requirement | How |
|---|---|
| Accuracy โฅ 85% | ConvLSTM on 4 distinct UCF50 classes; early stopping keeps the best weights |
| Fast inference (3โ5 s) | Only 20 sampled frames per clip; model loaded once and reused |
| Privacy | Uploaded videos are deleted immediately after prediction |
| Usability | One-page upload UI with per-class confidence bars |
| Error handling | Alerts for unsupported formats, unreadable videos and a missing model |
| Paper | Approach | Reported result |
|---|---|---|
| Yu & Yan, 2020 | Two-Stream CNN, CNN+LSTM, 3D CNN | CNN+LSTM best at 89.74% |
| Shekokar & Kale, 2021 | CNN with frame reduction | 86.21% |
| Gao et al., 2018 | Recurrent 3D CNN (3D CNN + LSTM) | Best among compared models |
| Akula et al., 2018 | 2D CNN on infrared images | 87.44% |
The consistent finding, that combining spatial and temporal modelling works best, led to the ConvLSTM design.
- More action classes and a larger training set
- Pose-based (skeleton) features for robustness to background clutter
- Live webcam mode inside the web app
- Deploy with Docker on a GPU server
- Akshata Kiran Bole
- Anusha Kaveramma B D
- Gagana Jain A
- Vijayalakshmi R
Guide: Teerthalakshmi A M, B.E., M.Tech., Assistant Professor, Dept. of ISE, Bahubali College of Engineering
This project is licensed under the MIT License.