Downloads · 30 days
0
Yingzhe/eye-open-closed-dinov2
eye-open-closed-dinov2 is a machine learning model from Yingzhe. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
DINOv2-ViT-Large fine-tuned on MRL Eye Dataset (NIR grayscale eye patches).
Downloads · 30 days
0
Access
Public
Updated Apr 13, 2026
Repo size
1.2 GB
Likes
0
Public
Click a slice to open those files.
.pth1.2 GB · 100%
From the Hugging Face model README
DINOv2-ViT-Large fine-tuned on MRL Eye Dataset (NIR grayscale eye patches).
| Metric | Value |
|---|---|
| Test Accuracy | 0.9924 |
| Test F1 Score | 0.9923 |
| Model Size | 303M params (1.2GB) |
| Input Size | 64×64 (grayscale, auto-converted to 3ch) |
| Training Data | MRL Eye Dataset (50,937 train / 16,981 test) |
# Install dependencies
pip install torch torchvision timm onnxruntime pillow
# Download model weights
pip install huggingface_hub
huggingface-cli download Yingzhe/eye-open-closed-dinov2 best_dinov2_eye.pth --local-dir .
python eye_open_closed_infer.py --image eye.jpg
Output:
eye.jpg: OPEN (confidence=0.9872)
python eye_open_closed_infer.py \
--input_dir ./eye_images/ \
--output_dir ./labeled_output/ \
--draw_label \
--conf_threshold 0.85
This will:
./eye_images/./labeled_output/./labeled_output/results.csv with all predictions# Strict: only trust predictions above 0.95
python eye_open_closed_infer.py --input_dir ./eyes/ --output_dir ./out/ --draw_label --conf_threshold 0.95
# Lenient: accept all predictions
python eye_open_closed_infer.py --input_dir ./eyes/ --output_dir ./out/ --draw_label --conf_threshold 0.50
python eye_open_closed_infer.py --input_dir ./eyes/ --output_dir ./out/ --device cuda
# Download ONNX model
huggingface-cli download Yingzhe/eye-open-closed-dinov2 dinov2_eye_classifier.onnx --local-dir .
# Run
pip install onnxruntime pillow
python eye_open_closed_infer.py --input_dir ./eyes/ --output_dir ./out/ --draw_label --onnx dinov2_eye_classifier.onnx
| Argument | Default | Description |
|---|---|---|
--image | - | Single image path |
--input_dir | - | Input directory (batch mode) |
--output_dir | - | Output directory for labeled images |
--weight | best_dinov2_eye.pth | PyTorch weight path |
--onnx | None | ONNX model path (alternative to PyTorch) |
--conf_threshold | 0.85 | Confidence below this → UNCERTAIN |
--draw_label | False | Draw prediction text on output images |
--device | cpu | cpu or cuda |
--csv | <output_dir>/results.csv | CSV output path |
filename,prediction,confidence
s0001_00001.png,OPEN,0.9987
s0002_00015.png,CLOSED,0.9921
s0003_00638.png,UNCERTAIN,0.5004
| Confidence Range | Awake | Sleepy |
|---|---|---|
| ≥ 0.95 | 95.8% | 99.0% |
| 0.85 ~ 0.95 | 2.6% | 0.5% |
| 0.70 ~ 0.85 | 1.2% | 0.3% |
| < 0.70 | 0.4% | 0.2% |
Recommendation: Use --conf_threshold 0.85 for pseudo-label generation. This filters out ~3% of uncertain samples while keeping accuracy > 0.998.
See train_dinov2.py for training code. Train on MRL Eye Dataset:
kaggle datasets download -d akashshingha850/mrl-eye-dataset