File size: 1,198 Bytes
8bbb872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ui/

Live camera demo and real-time inference pipeline.

## 1. Files

| File | Description |
|------|-------------|
| `pipeline.py` | Inference pipelines: `FaceMeshPipeline`, `MLPPipeline`, `XGBoostPipeline` |
| `live_demo.py` | OpenCV webcam window with mesh overlay and focus classification |

## 2. Pipelines

| Pipeline | Features | Model | Source |
|----------|----------|-------|--------|
| `FaceMeshPipeline` | Head pose + eye geometry | Rule-based fusion | `models/head_pose.py`, `models/eye_scorer.py` |
| `MLPPipeline` | 10 selected features | PyTorch MLP | `checkpoints/model_best.joblib` |
| `XGBoostPipeline` | 10 selected features | XGBoost | `models/xgboost/checkpoints/face_orientation_best.json` |

## 3. Running

```bash
# default mode (cycles through available pipelines)
python ui/live_demo.py

# start directly in XGBoost mode
python ui/live_demo.py --xgb
```

### Controls

| Key | Action |
|-----|--------|
| `m` | Cycle mesh overlay (full → contours → off) |
| `p` | Switch pipeline (FaceMesh → MLP → XGBoost) |
| `q` | Quit |

## 4. Integration

The same pipelines are used by the FastAPI backend (`main.py`) for WebSocket-based video inference in the React app.