State-of-the-art human action recognition model trained on Stanford 40 Actions dataset. GitHub project link -> human-action-classification
This model performs real-time human action classification from images, recognizing 40 different human activities. It combines a ResNet34 backbone with optional MediaPipe pose estimation for enhanced accuracy.
All models trained on Stanford 40 Actions dataset:
| Model | Accuracy | Macro F1 | Parameters | Size | Inference Time* |
|---|---|---|---|---|---|
| ResNet50 | 88.5% | 0.8842 | 23.5M | 94MB | ~30ms |
| ResNet34 (this model) | 86.4% | 0.8618 | 21.3M | 85MB | ~25ms |
| ResNet18 | 82.3% | 0.8178 | 11.2M | 45MB | ~18ms |
| MobileNet V3 Large | 82.1% | 0.8169 | 5.4M | 20MB | ~15ms |
| ViT Base | 76.8% | 0.7650 | 86M | 330MB | ~45ms |
| MobileNet V3 Small | 74.35% | 0.7350 | 2.5M | 10MB | ~10ms |
*Single image on NVIDIA GTX 1050 Ti
| Model | Accuracy (%) | Macro Precision | Macro Recall | Macro F1 | Weighted F1 |
|---|---|---|---|---|---|
| ResNet50 | 88.5 | 0.8874 | 0.8850 | 0.8842 | 0.8842 |
| ResNet34 | 86.4 | 0.8686 | 0.8640 | 0.8618 | 0.8618 |
| ResNet18 | 82.3 | 0.8211 | 0.8230 | 0.8178 | 0.8178 |
| MobileNet V3 Large | 82.1 | 0.8216 | 0.8210 | 0.8169 | 0.8169 |
| ViT Base Patch16 | 76.8 | 0.7774 | 0.7680 | 0.7650 | 0.7650 |
| MobileNet V3 Small | 74.35 | 0.7382 | 0.7435 | 0.7350 | 0.7350 |
Trade-offs:
pip install git+https://github.com/dronefreak/human-action-classification.git
Weights on this repo:
model.safetensors+config.jsonat the root are the ResNet34 model (whathf://dronefreak/human-action-classification-stanford40loads). Every variant also has<variant>/model.safetensors,<variant>/config.json(model name, class names in training order) and the original<variant>/best.pth(with training state). Variants:mobilnetv3_small,mobilnetv3_large,resnet18,resnet34,resnet50.
from hac import ActionPredictor
# Initialize predictor
predictor = ActionPredictor(
model_path="hf://dronefreak/human-action-classification-stanford40",
device='cuda'
)
# Predict on image
result = predictor.predict_image('photo.jpg', top_k=3)
# Print results
print(f"Action: {result['action']['top_class']}")
print(f"Confidence: {result['action']['top_confidence']:.2%}")
# Top 3 predictions
for pred in result['action']['predictions']:
print(f" {pred['class']}: {pred['confidence']:.2%}")
predictor = ActionPredictor(
model_path="hf://dronefreak/human-action-classification-stanford40",
use_pose_estimation=True, # Enable MediaPipe
device='cuda'
)
result = predictor.predict_image('photo.jpg', return_pose=True)
print(f"Detected pose: {result['pose']['class']}")
print(f"Action: {result['action']['top_class']}")
from pathlib import Path
image_paths = list(Path('images/').glob('*.jpg'))
results = predictor.predict_batch(image_paths, batch_size=32)
for img_path, result in zip(image_paths, results):
print(f"{img_path.name}: {result['action']['top_class']}")
Evaluated on Stanford 40 Actions test set (5,532 images):
| Metric | Score |
|---|---|
| Accuracy | 86.4% |
| Macro F1-Score | 0.8618 |
| Weighted F1-Score | 0.8618 |
| Macro Precision | 0.8686 |
| Macro Recall | 0.8640 |
| Class | F1-Score |
|---|---|
| Applauding | 0.935 |
| Jumping | 0.925 |
| Running | 0.918 |
| Waving Hands | 0.912 |
| Drinking | 0.905 |
Most commonly confused actions:
Full metrics available in metrics.json
Please note that the proposed train-test split is a bit unconventional, which is why I had to create a custom train-test split of 80-20, which is a standard in machine learning practises.
# Training augmentation
transforms.Compose([
transforms.RandomResizedCrop(224),
transforms.RandomHorizontalFlip(),
transforms.ColorJitter(brightness=0.2, contrast=0.2),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
])
This approach reduced overfitting from 99% train / 62% test → 82% train / 86% test.
from hac.evaluation import evaluate_model
# Evaluate on test set
metrics = evaluate_model(
checkpoint='resnet34_best.pth',
data_dir='stanford40/',
split='test'
)
print(f"Accuracy: {metrics['accuracy']:.2%}")
print(f"F1-Score: {metrics['f1_macro']:.4f}")
The model inherits biases from the Stanford 40 dataset:
Users should evaluate performance on their specific use case.
@software{saksena2025hac,
author = {Saksena, Saumya Kumaar},
title = {Human Action Classification v2.0},
year = {2025},
url = {https://github.com/dronefreak/human-action-classification},
version = {2.0}
}
Saumya Kumaar Saksena
Apache License 2.0 - Free for research and commercial use.
See LICENSE for full details.
resnet50/best.pth 284 MBresnet34/best.pth 256 MBresnet18/best.pth 134 MBresnet50/model.safetensors 95 MBmodel.safetensors 85 MBresnet34/model.safetensors 85 MBmobilnetv3_large/best.pth 51 MBresnet18/model.safetensors 45 MBmobilnetv3_small/best.pth 19 MBmobilnetv3_large/model.safetensors 17 MBmobilnetv3_small/model.safetensors 6 MB