Instructions to use BDRC/6-way-balanced-script-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BDRC/6-way-balanced-script-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="BDRC/6-way-balanced-script-classifier") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("BDRC/6-way-balanced-script-classifier", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from BDRC/6-way-balanced-script-classifier: direct link, hf CLI and curl.
- Browser
- Download file 4.25 kB
-
https://huggingface.co/BDRC/6-way-balanced-script-classifier/resolve/main/README.md
- Command line
-
hf download hf://BDRC/6-way-balanced-script-classifier/README.md
-
curl -L -H "Authorization: Bearer $HF_TOKEN" -o README.md https://huggingface.co/BDRC/6-way-balanced-script-classifier/resolve/main/README.md
4.25 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 | |
| - multiclass | |
| - balanced | |
| library_name: transformers | |
| pipeline_tag: image-classification | |
| base_model: facebook/dinov3-vits16-pretrain-lvd1689m | |
| datasets: | |
| - BDRC/6-class-balanced-script-classification-dataset | |
| - BDRC/script-classification-Benchmark | |
| metrics: | |
| - f1 | |
| - accuracy | |
| # 6-Way Tibetan Script Classifier (DINOv3 ViT-S) | |
| Fine-tuned [DINOv3 ViT-S](https://huggingface.co/facebook/dinov3-vits16-pretrain-lvd1689m) for six Tibetan script families: | |
| **Danyig**, **Druma**, **Gyuyig**, **Pedri**, **Tsugdri**, **Uchen** | |
| **Experiment:** `dinov3_6way_script_classifier` (`6_way_script_classification`) | |
| **Pooling:** Global average pooling over patch tokens (skips CLS + register tokens) | |
| **Weights:** `final_model.pt` (best validation macro-F1 across stages A/B) | |
| ## Data | |
| | Split | Dataset | | |
| |-------|---------| | |
| | Train / val | [BDRC/6-class-balanced-script-classification-dataset](https://huggingface.co/datasets/BDRC/6-class-balanced-script-classification-dataset) | | |
| | Test (benchmark) | [BDRC/script-classification-Benchmark](https://huggingface.co/datasets/BDRC/script-classification-Benchmark) | | |
| ## Preprocessing | |
| | Split | Mode | Notes | | |
| |-------|------|-------| | |
| | train | `center_crop_affine` | center crop 448 + affine (±8.0°, translate 0.04, scale [0.96, 1.04]) | | |
| | val | `center_crop` | center crop | | |
| | test | `center_crop` | center crop (benchmark) | | |
| Processor size: **448** px. Inference default: `--preprocess center_crop --preprocess-size 448`. | |
| ## Benchmark test metrics (n=540) | |
| | Metric | All | BDRC (360) | Synthetic (180) | | |
| |--------|----:|----:|----:| | |
| | Accuracy | 78.1% | 69.4% | 95.6% | | |
| | Macro F1 | 0.769 | 0.647 | 0.954 | | |
| **Best val checkpoint:** `best_stage_b_last_blocks.pt` epoch 16 macro-F1 0.755 | |
| ### Training hyperparameters | |
| | Parameter | Value | | |
| |-----------|-------| | |
| | `lr_head_a` | `5e-05` | | |
| | `lr_backbone_b` | `1e-06` | | |
| | `lr_head_b` | `1e-05` | | |
| | `epochs_a` | `10` | | |
| | `epochs_b` | `25` | | |
| | `unfreeze_blocks_b` | `4` | | |
| | `scheduler` | `cosine` | | |
| | `warmup_epochs_a` | `0` | | |
| | `warmup_epochs_b` | `0` | | |
| | `warmup_start_factor` | `1.0` | | |
| | `min_lr_ratio` | `0.01` | | |
| | `early_stop_patience` | `8` | | |
| | `class_weight_mode` | `balanced` | | |
| | `label_smoothing` | `0.1` | | |
| | `dropout` | `0.5` | | |
| | `weight_decay` | `0.1` | | |
| | `grad_clip_norm` | `1.0` | | |
| ### Per-class (benchmark test) | |
| ``` | |
| precision recall f1-score support | |
| Danyig 0.76 0.62 0.68 90 | |
| Druma 0.88 0.91 0.90 90 | |
| Gyuyig 0.65 0.94 0.77 90 | |
| Pedri 0.65 0.86 0.74 90 | |
| Tsugdri 0.97 0.37 0.53 90 | |
| Uchen 1.00 0.99 0.99 90 | |
| accuracy 0.78 540 | |
| macro avg 0.82 0.78 0.77 540 | |
| weighted avg 0.82 0.78 0.77 540 | |
| ``` | |
| ## Files | |
| | File | Description | | |
| |------|-------------| | |
| | `final_model.pt` | Best val-F1 weights + label maps + test metrics | | |
| | `results.json` | Full metrics, history, resolved config | | |
| | `config.yaml` | Training config used for this run | | |
| | `model_card.json` | Summary metadata | | |
| | `confusion_matrix.json` / `.png` | Benchmark test CM | | |
| | `training_history.png` | Stage loss / val F1 curves | | |
| | `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 center_crop --preprocess-size 448 | |
| ``` | |
| ## Reproduce training | |
| ```bash | |
| python scripts/download_hf_6class_datasets.py | |
| python experiments/synthetic_data/train.py | |
| ``` | |
| **Model repo:** [BDRC/6-way-balanced-script-classifier](https://huggingface.co/BDRC/6-way-balanced-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. | |