File size: 4,365 Bytes
50a3c34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
license: cc-by-nc-4.0
library_name: pytorch
pipeline_tag: video-classification
tags:
  - video-classification
  - action-recognition
  - mvit
  - workplace-monitoring
  - computer-vision
datasets:
  - charades
metrics:
  - accuracy
  - f1
---

# WorkSight Activity Model (MViT-v2-S, fine-tuned)

A video action-recognition model that classifies **what a person is doing in a 3-second clip**
into six workplace activities. It is the classifier inside **WorkSight**, a real-time monitor that
tracks every person in a CCTV-style feed and flags penalty activities.

| Label | Meaning in WorkSight |
|---|---|
| `working` | 🟢 productive (laptop, keyboard, paper, reading) |
| `using_phone` | 🔴 penalty |
| `sleeping` | 🔴 penalty |
| `sitting_idle` | 🔴 penalty |
| `eating` | 🔴 penalty (eating or drinking) |
| `walking` | 🟡 neutral |

Predictions below a confidence of **0.60** are reported as `uncertain` instead of a label.

## Results

Test set: 3,045 clips from **30 people never seen in training** (subject-wise split).

| Model | Test accuracy |
|---|---|
| Frozen MViT features + logistic regression (baseline) | 52.0% |
| Frozen MViT features + classifier head, rebuilt dataset | 69.5% |
| **This model** (person-crop view, as used live) | **74.2%** |
| **This model** (4-view test-time augmentation) | **74.9%** (macro-F1 0.75) |

| Class | Precision | Recall | F1 |
|---|---|---|---|
| eating | 0.83 | 0.75 | 0.79 |
| sitting_idle | 0.60 | 0.66 | 0.63 |
| sleeping | 0.86 | 0.83 | 0.85 |
| using_phone | 0.68 | 0.72 | 0.70 |
| walking | 0.79 | 0.85 | 0.82 |
| working | 0.70 | 0.69 | 0.70 |

With the 0.60 `uncertain` threshold, the labels that are shown are **80% accurate** on unseen people;
15% of known activities and 34% of activities outside the six classes are reported as `uncertain`.

## Training

- **Architecture:** torchvision `mvit_v2_s`, initialised from Kinetics-400 weights, new 6-class head.
- **Data:** 19,466 three-second clips cut from the Charades dataset (13,227 train / 3,194 val /
  3,045 test), mapped from 16 Charades actions to the 6 classes. Windows that overlap a conflicting
  action are dropped, and `sitting_idle` excludes anyone handling a phone, laptop, book, food or cup.
- **Views:** 50% full-frame random crops, 50% person crops made exactly like the live tracker's
  (YOLO11 box, 18% margin, resized to 224×224); random 2.2–3 s sub-windows, flips, brightness/contrast jitter.
- **Optimisation:** AdamW (lr 1e-4 backbone, 1e-3 head, weight decay 0.05), cosine schedule with warm-up,
  label smoothing 0.1, square-root class weights, bf16 mixed precision, effective batch 16, 8 epochs.
- **Compute:** ~5 hours of fine-tuning on a single laptop GPU (RTX 4060, 8 GB);
  ~6.5 hours end to end including dataset preparation and the baseline.

## Usage

Input: 16 RGB frames sampled evenly from ~3 seconds, 224×224, normalised with mean 0.45 / std 0.225,
shaped `(batch, 3, 16, 224, 224)`.

```bash
pip install torch torchvision safetensors opencv-python huggingface_hub
```

```python
from huggingface_hub import snapshot_download
import sys

repo = snapshot_download("MMMJavid/WorkSight-Activity-MViT")
sys.path.insert(0, repo)
from inference import load_model, read_clip, predict

model, cfg = load_model(repo)
label, probs = predict(model, cfg, read_clip("clip.mp4"))
print(label, probs)
```

For best results, crop around the person first (`read_clip(path, person=True)`, needs `ultralytics`),
since that is how the model is used in the live monitor.

## Limitations

- Trained on Charades home videos (mostly one person, at home); real office footage is a domain shift.
- `working` covers laptop, paper and reading, not keyboard typing only.
- `sleeping` was learned from people lying down; a head-down-on-desk nap may be missed.
- About two thirds of activities outside the six classes still receive a confident label.

## Responsible use

This model observes people. Use it only with the informed consent of the people being recorded and in
line with local privacy and employment law. Its outputs are probabilistic and sometimes wrong; they
should support human review, not trigger automatic disciplinary action.

## License

CC BY-NC 4.0 (non-commercial), because the training data (Charades) is licensed for non-commercial
research use. The Kinetics-400 initialisation comes from torchvision.