Image Classification
Transformers
Tibetan
tibetan
script-classification
dinov3
binary
Eroux's picture
Clarify code and weights licenses
de41fdd verified
|
Raw History Blame Contribute Delete
4.22 kB
---
license: other
license_name: dinov3-license
license_link: https://huggingface.co/facebook/dinov3-vits16-pretrain-lvd1689m/blob/main/LICENSE.md
language:
- bo
tags:
- image-classification
- tibetan
- script-classification
- dinov3
- binary
library_name: transformers
pipeline_tag: image-classification
base_model: facebook/dinov3-vits16-pretrain-lvd1689m
datasets:
- BDRC/danyig-pedri-binary-balanced-script-classification-dataset
metrics:
- f1
- accuracy
- auc
---
# Danyig vs Pedri Binary Script Classifier (DINOv3 ViT-S)
Fine-tuned [DINOv3 ViT-S](https://huggingface.co/facebook/dinov3-vits16-pretrain-lvd1689m) for parent script classification:
**Danyig**, **Pedri**
**Experiment:** `dinov3_danyig_pedri_binary` (`danyig_pedri_binary_classification`)
**Pooling:** ViT **CLS token** (`last_hidden_state[:, 0, :]`)
**Weights:** `final_model.pt` (best validation macro-F1 across stages A/B/C)
## Data
| Split | Source |
|-------|--------|
| Train / val / test | [BDRC/danyig-pedri-binary-balanced-script-classification-dataset](https://huggingface.co/datasets/BDRC/danyig-pedri-binary-balanced-script-classification-dataset) |
Test split: balanced benchmark (60 images per parent class, held out of training).
## Preprocessing
| Split | Mode | Size |
|-------|------|-----:|
| train | `resize_letterbox` | 448 |
| val | `resize_letterbox` | 448 |
| test | `resize_letterbox` | 448 |
## Validation metrics (n=118)
| Metric | Value |
|--------|------:|
| Accuracy | 81.4% |
| Macro F1 | 0.814 |
| Weighted F1 | 0.813 |
| AUC-ROC | 0.863 |
| Loss | 0.5729 |
**Best checkpoint:** `best_stage_c_last_blocks.pt` epoch 12 val macro-F1 0.814
### Per-class (validation)
```
precision recall f1-score support
Danyig 0.84 0.78 0.81 60
Pedri 0.79 0.84 0.82 58
accuracy 0.81 118
macro avg 0.81 0.81 0.81 118
weighted avg 0.82 0.81 0.81 118
```
## Test / benchmark metrics (n=120)
| Metric | Value |
|--------|------:|
| Accuracy | 85.0% |
| Macro F1 | 0.849 |
| Weighted F1 | 0.849 |
| AUC-ROC | 0.914 |
| Loss | 0.4417 |
### Per-class (test)
```
precision recall f1-score support
Danyig 0.90 0.78 0.84 60
Pedri 0.81 0.92 0.86 60
accuracy 0.85 120
macro avg 0.86 0.85 0.85 120
weighted avg 0.86 0.85 0.85 120
```
## Training
| Stage | Epochs | LR head | LR backbone | Unfrozen blocks |
|-------|-------:|--------:|------------:|----------------:|
| A | 7 | 0.0005 | — | 0 |
| B | 10 | 0.0001 | 1e-05 | 4 |
| C | 12 | 5e-05 | 1.5e-05 | 8 |
| Setting | Value |
|---------|-------|
| Scheduler | `cosine_warmup` |
| Class weights | `custom` |
| Label smoothing | 0.05 |
| Dropout | 0.1 |
## Confusion matrix (test)
![Confusion matrix](confusion_matrix.png)
| True \ Pred | Danyig | Pedri |
|---|---:|---:|
| **Danyig** | 47 | 13 |
| **Pedri** | 5 | 55 |
## Files
| File | Description |
|------|-------------|
| `final_model.pt` | Best val-F1 weights + label maps |
| `results.json` | Full metrics, history, warm-start info |
| `config.yaml` | Training config |
| `model_card.json` | Summary metadata |
| `confusion_matrix.json` / `.png` | Test CM |
| `training_history.png` | Stage loss / val F1 curves |
| `split_stats.json` / `.md` | Per-class split counts |
| `inference.py` | Classify image paths |
| `requirements-inference.txt` | Pip deps |
## Inference
```bash
pip install -r requirements-inference.txt
python inference.py --checkpoint final_model.pt --image path/to/page.jpg --preprocess resize_letterbox --preprocess-size 448
```
## Reproduce training
```bash
python experiments/danyig-pedri-subclass/train.py
```
**Model repo:** [BDRC/danyig-pedri-binary-script-classifier](https://huggingface.co/BDRC/danyig-pedri-binary-script-classifier)
## License
The fine-tuned model weights are derivative works of DINOv3 and are distributed
under the [DINOv3 License](LICENSE.md). The original inference code in this
repository is available under the Apache License 2.0.