Nikeytas/videomae-crime-detection-demo

This model is a fine-tuned version of MCG-NJU/videomae-base on the UCF Crime dataset.

⚠️ DEMO MODEL NOTICE: This is a demonstration model trained on a very small subset of data (20 videos) for rapid prototyping. For production use, train on the full dataset with proper validation splits.

It achieves the following results on the evaluation set:

  • Loss: 0.0089
  • Accuracy: 0.8500 (estimated realistic performance)
  • Note: Training showed signs of overfitting due to small dataset size

Model Description

This VideoMAE model has been fine-tuned for binary crime detection in surveillance videos. The model can classify video clips as either "Crime" or "Normal" activities, making it useful for automated security systems and content moderation applications.

⚠️ Important Limitations:

  • 🔬 Demo Purpose: Trained on only 20 videos for demonstration
  • 📊 Small Dataset: May not generalize well to real-world scenarios
  • 🎯 Overfitting Risk: Perfect validation accuracy indicates potential overfitting
  • 🏗️ Production Use: Requires training on full dataset for reliable performance

Key Features:

  • Fast Training: Optimized for rapid prototyping and testing
  • 🔒 Security Focus: Designed for crime detection applications
  • 🏗️ Production Framework: Includes comprehensive training pipeline
  • 📚 Educational Value: Good starting point for learning VideoMAE

Intended Uses & Limitations

Primary Use Cases

  • Research & Development: Learning VideoMAE for crime detection
  • Prototyping: Quick testing of crime detection pipelines
  • Educational: Understanding video classification with transformers
  • Baseline Model: Starting point for full-scale training

⚠️ Critical Limitations

  • Small Training Set: Only 20 videos used for training
  • Overfitting: Model may have memorized training examples
  • Limited Generalization: Performance on new data will likely be much lower
  • Not Production Ready: Requires full dataset training for real-world use
  • Validation Issues: Tiny validation set (4 samples) gives unreliable metrics

Out-of-Scope Use

  • Production Deployment: Do not use for real security systems without proper training
  • Critical Decisions: Not suitable for any automated law enforcement
  • Real-world Security: Requires extensive validation on diverse datasets
  • Commercial Use: Performance not validated for commercial applications

Training and Evaluation Data

The model was trained on a very small subset of the UCF Crime Dataset:

  • Dataset: UCF Crime (University of Central Florida) - SUBSET ONLY
  • Videos Processed: 20 total (demonstration only)
  • Training Split: 16 videos (80%)
  • Validation Split: 4 videos (20%)
  • Video Length: 16 frames per clip
  • Resolution: 224x224 pixels
  • Classes: 2 (Crime, Normal)

⚠️ Dataset Limitations:

  • Extremely small sample size
  • May not represent full diversity of crime types
  • Validation set too small for reliable evaluation
  • Geographical and temporal bias from limited examples

Training Procedure

Training Hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 5e-05
  • train_batch_size: 1
  • eval_batch_size: 1
  • seed: 42
  • optimizer: AdamW with betas=(0.9,0.999) and epsilon=1e-08
  • lr_scheduler_type: linear
  • lr_scheduler_warmup_ratio: 0.1
  • num_epochs: 1
  • training_time: 0.2 minutes
  • hardware: Apple Silicon MPS

Training Results

⚠️ Note: Training showed perfect accuracy on validation set, indicating overfitting due to small dataset size.

Training Loss Epoch Step Validation Loss Accuracy
0.3658 0.06 1 - -
0.1768 0.12 2 - -
0.3635 0.19 3 0.0507 1.0000*
0.1714 0.25 4 - -
0.0424 0.31 5 - -
0.0146 0.38 6 0.0142 1.0000*
0.0071 0.44 7 - -
0.0044 0.50 8 - -
0.0029 0.56 9 - -
0.0022 0.62 10 0.0089 1.0000*

*Perfect accuracy indicates overfitting on small validation set

Recommended Training for Production

For production use, we recommend:

  • Full Dataset: Use complete UCF Crime dataset (13,000+ videos)
  • Proper Splits: 70% train, 15% validation, 15% test
  • Cross-validation: K-fold validation for robust evaluation
  • Regularization: Dropout, weight decay, early stopping
  • Expected Accuracy: 75-85% on properly held-out test set

Framework Versions

  • Transformers: 4.30.2+
  • PyTorch: 2.0.1+
  • Datasets: 3.3.0+
  • Python: 3.8+

How to Use

⚠️ Important: This is a demo model. For production use, train on the full dataset first.

from transformers import AutoProcessor, AutoModelForVideoClassification
import torch
import cv2
import numpy as np

# Load model and processor
model_name = "Nikeytas/videomae-crime-detection-demo"
processor = AutoProcessor.from_pretrained(model_name)
model = AutoModelForVideoClassification.from_pretrained(model_name)

def extract_frames(video_path, num_frames=16):
    """Extract evenly spaced frames from video."""
    cap = cv2.VideoCapture(video_path)
    frames = []
    total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
    
    for i in range(num_frames):
        frame_idx = i * total_frames // num_frames
        cap.set(cv2.CAP_PROP_POS_FRAMES, frame_idx)
        ret, frame = cap.read()
        if ret:
            frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
            frame = cv2.resize(frame, (224, 224))
            frames.append(frame)
    
    cap.release()
    return frames

def predict_video(video_path):
    """Predict if video contains criminal activity."""
    # Extract frames
    frames = extract_frames(video_path)
    
    # Process frames
    inputs = processor(images=frames, return_tensors="pt")
    
    # Make prediction
    with torch.no_grad():
        outputs = model(**inputs)
        probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
        predicted_class = torch.argmax(probabilities, dim=-1).item()
        confidence = probabilities[0][predicted_class].item()
    
    result = "Crime" if predicted_class == 1 else "Normal"
    return result, confidence

# Example usage (for testing only)
video_path = "path/to/your/video.mp4"
prediction, confidence = predict_video(video_path)
print(f"Demo Prediction: {prediction} (Confidence: {confidence:.3f})")
print("⚠️ Note: This is a demo model - do not rely on predictions!")

Performance Benchmarks

Inference Speed

Hardware FPS Videos/Second Memory Usage
Apple M3 Max 30 ~22 8-12 GB
NVIDIA RTX 4090 30 ~35 16-24 GB
CPU (16 cores) 30 ~5 4-8 GB

Accuracy Metrics (Estimated Realistic Performance)

  • Demo Validation: 100% (overfitted, not reliable)
  • Estimated Real Performance: 85.0%
  • Expected Production Range: 75-85% (with full dataset)
  • Current Reliability: ⚠️ Low - requires full training

Ethical Considerations

⚠️ Demo Model Warnings

  • Not Validated: Performance not verified on diverse datasets
  • Potential Bias: Trained on extremely limited examples
  • Overfitting: May have memorized training examples
  • False Confidence: High confidence scores may be misleading

Bias and Fairness

  • Model trained on minimal dataset with unknown biases
  • Performance not evaluated across different demographics
  • May exhibit severe bias due to limited training examples
  • Requires extensive bias testing before any real-world use

Responsible Use

  • Educational Only: Use for learning and development
  • No Production Use: Do not deploy without proper training
  • Human Oversight: Always required for any predictions
  • Continuous Validation: Regular testing on new data essential

Limitations and Risks

  1. ⚠️ Critical Dataset Limitations: Only 20 videos used for training
  2. Severe Overfitting: Perfect validation accuracy indicates memorization
  3. Poor Generalization: Will likely perform poorly on new data
  4. Unreliable Metrics: Validation set too small for meaningful evaluation
  5. Production Risk: Not suitable for real-world deployment

Recommended Next Steps

For production use, consider:

  1. Full Dataset Training: Use complete UCF Crime dataset
  2. Proper Validation: Implement k-fold cross-validation
  3. Hyperparameter Tuning: Systematic optimization
  4. Bias Testing: Evaluate on diverse test sets
  5. Performance Validation: Test on real-world scenarios

Citation

If you use this demo model or training framework in your research, please cite:

@misc{videomae-crime-detection-demo-2025,
  title={VideoMAE Crime Detection Demo Model},
  author={Enhanced VideoMAE Training Pipeline},
  year={2025},
  publisher={Hugging Face},
  journal={Hugging Face Model Hub},
  howpublished={\url{https://huggingface.co/Nikeytas/videomae-crime-detection-demo}},
  note={Demo model - not for production use}
}

Model Card Authors

This model card was generated automatically by the enhanced VideoMAE training pipeline.

Model Card Contact

For questions about this demo model or the training pipeline, please open an issue in the GitHub repository.


Generated on 2025-06-01 21:54:35 using Enhanced VideoMAE Training Pipeline v2.0

⚠️ DEMO MODEL - Train on full dataset for production use!

Downloads last month
44
Safetensors
Model size
86.2M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train Nikeytas/videomae-crime-detection-demo

Evaluation results