Views
No views yet
| Model | Backbone | Frames | Threshold | F1 | GPU Latency | Strategy |
|---|---|---|---|---|---|---|
final_best (R(2+1)D-18 optimized) | r2plus1d_18 | 32 | 0.5 | 0.93 | ~21 ms | Step 2 ablation, no retrain |
final_x3d_realtime (X3D-M realtime) | x3d_m | 16 | 0.4 | 0.93 | ~3.77 ms | Full retrain @16 frames |
final_x3d_realtime nhanh hơn ~5.6× trên GPU và phù hợp deploy realtime.⚠️ Lưu ý quan trọng khi inference:
final_x3d_realtimedùng 16 frames (không phải 32) và threshold = 0.4 (không phải 0.5).final_best(R(2+1)D-18) dùng 32 frames, threshold 0.5 như mặc định.
| Model | Backbone | Accuracy | Params | Size | Note |
|---|---|---|---|---|---|
| X3D-M | x3d_m | ~92.0% | 3.0M | ~35 MB | Baseline trước ablation |
| I3D-R50 | i3d_r50 | ~90.75% | 27.2M | ~312 MB | Baseline |
| SlowFast-R50 | slowfast_r50 | ~92.5% | 33.6M | ~386 MB | Baseline |
| R(2+1)D-18 | r2plus1d_18 | ~93.0% | 31.3M | ~358 MB | Baseline cho final_best |
Số liệu accuracy là kết quả trên tập validation của RWF-2000 (split 80/10/10).
school-violence-detection-models/
├── README.md # Model card này
├── .gitattributes # Git LFS config cho file .pt
├── config.yaml # Config dùng để train/infer
├── final/ # ⭐ 2 model optimized sau ablation
│ ├── final_best.pt # R(2+1)D-18, 32 frames, thr=0.5
│ ├── final_x3d_realtime.pt # X3D-M, 16 frames, thr=0.4
│ └── MODEL_CARD.md
├── x3d_m/ # Baseline
│ ├── x3d_m_best.pt
│ ├── x3d_summary.json
│ ├── x3d_confusion_matrix.png
│ ├── x3d_training_history.png
│ └── MODEL_CARD.md
├── i3d_r50/
│ ├── i3d_r50_best.pt
│ ├── i3d_summary.json
│ ├── i3d_confusion_matrix.png
│ ├── i3d_training_history.png
│ └── MODEL_CARD.md
├── slowfast_r50/
│ ├── slowfast_best.pt
│ ├── slowfast_summary.json
│ ├── slowfast_confusion_matrix.png
│ ├── slowfast_training_history.png
│ └── MODEL_CARD.md
└── r2plus1d_18/
├── r2plus1d_best.pt
├── r2plus1d_confusion_matrix.png
├── r2plus1d_training_history.png
└── MODEL_CARD.mdpip install torch torchvision pytorchvideo opencv-python-headless pyyaml1from huggingface_hub import hf_hub_download
2
3# Recommended: final optimized models
4ckpt_path = hf_hub_download(
5 repo_id="visionlab-ai/school-violence-detection-models",
6 filename="final/final_x3d_realtime.pt", # or "final/final_best.pt"
7)
8
9# Or one of the baselines
10ckpt_path = hf_hub_download(
11 repo_id="visionlab-ai/school-violence-detection-models",
12 filename="x3d_m/x3d_m_best.pt",
13)1import torch
2import torch.nn.functional as F
3from pytorchvideo.models.hub import x3d_m
4
5# Build architecture (must match training config)
6model = x3d_m(pretrained=False)
7model.blocks[5].proj = torch.nn.Linear(2048, 2) # 2 classes: non-violent / violent
8
9# Load checkpoint
10checkpoint = torch.load(ckpt_path, map_location="cpu")
11state_dict = checkpoint.get("model", checkpoint.get("model_state_dict", checkpoint))
12model.load_state_dict(state_dict)
13model.eval()
14
15# Input: (B, C=3, T=32, H=224, W=224), normalized to mean=0.45, std=0.225
16# video_tensor = preprocess_video("video.mp4")
17# with torch.no_grad():
18# logits = model(video_tensor)
19# probs = F.softmax(logits, dim=1)
20# # probs[0][0] = non-violent, probs[0][1] = violent⚠️ Bốn mô hình có wrapper class riêng (xemmodel/trong repo source). Để load đúng kiến trúc, khuyến nghị dùngmodel_registry.pytừ repo source code, hoặc xem chi tiết trong từngMODEL_CARD.md.
1@misc{school_violence_detection_2026,
2 title = {School Violence Detection: A Comparative Study of 3D CNN Architectures},
3 author = {Nguyen, Nauthui7},
4 year = {2026},
5 school = {University of Information Technology (UIT), VNU-HCM},
6 note = {Graduation thesis}
7}