Instructions to use Roboflow/rf-detr-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Roboflow/rf-detr-large with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("object-detection", model="Roboflow/rf-detr-large")# Load model directly from transformers import AutoImageProcessor, AutoModelForObjectDetection processor = AutoImageProcessor.from_pretrained("Roboflow/rf-detr-large") model = AutoModelForObjectDetection.from_pretrained("Roboflow/rf-detr-large") - Notebooks
- Google Colab
- Kaggle
Update README.md
#2
by hietraan - opened
README.md
CHANGED
|
@@ -1,94 +1,231 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
| 3 |
tags:
|
|
|
|
| 4 |
- object-detection
|
| 5 |
-
-
|
| 6 |
-
|
| 7 |
-
-
|
| 8 |
-
|
| 9 |
-
library_name: transformers
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
-
|
| 23 |
-
- **Decoder:** **Deformable DETR**-style decoder with multi-scale deformable cross-attention; depth and input resolution vary by checkpoint (NAS frontier).
|
| 24 |
-
- **Queries:** DETR-style object queries with bipartite matching and auxiliary decoder losses for training stability.
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
- **
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
##
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
```python
|
| 38 |
-
from
|
| 39 |
-
import torch
|
| 40 |
from PIL import Image
|
| 41 |
-
import requests
|
| 42 |
|
| 43 |
-
|
| 44 |
-
image = Image.open(
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
| 47 |
-
model = RfDetrForObjectDetection.from_pretrained("stevenbucaille/rf-detr-large")
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
|
|
|
| 51 |
|
| 52 |
-
#
|
| 53 |
-
# let's only keep detections with score > 0.35
|
| 54 |
-
target_sizes = torch.tensor([image.size[::-1]])
|
| 55 |
-
results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.35)[0]
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
print(
|
| 60 |
-
f"Detected {model.config.id2label[label.item()]} with confidence "
|
| 61 |
-
f"{round(score.item(), 3)} at location {box}"
|
| 62 |
-
)
|
| 63 |
```
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
```
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
Detected remote with confidence 0.135 at location [338.6, 76.26, 369.93, 130.59]
|
| 72 |
-
Detected remote with confidence 0.268 at location [258.99, 54.31, 291.03, 78.72]
|
| 73 |
-
Detected remote with confidence 0.119 at location [335.04, 150.52, 352.63, 186.95]
|
| 74 |
```
|
| 75 |
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
|
| 79 |
|
| 80 |
-
|
| 81 |
|
| 82 |
```bibtex
|
| 83 |
-
@misc{
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
}
|
| 92 |
```
|
| 93 |
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- vi
|
| 4 |
license: apache-2.0
|
| 5 |
+
library_name: rfdetr
|
| 6 |
+
pipeline_tag: object-detection
|
| 7 |
tags:
|
| 8 |
+
- rf-detr
|
| 9 |
- object-detection
|
| 10 |
+
- document-layout
|
| 11 |
+
- textbook
|
| 12 |
+
- fine-tuned
|
| 13 |
+
|
|
|
|
| 14 |
---
|
| 15 |
|
| 16 |
+
<div align="center">
|
| 17 |
|
| 18 |
+
# π VT-DETR β Textbook Layout Detection
|
| 19 |
|
| 20 |
+
**RF-DETR Large fine-tuned for Vietnamese textbook document layout analysis**
|
| 21 |
|
| 22 |
+
[](https://github.com/roboflow/rf-detr/blob/develop/LICENSE)
|
| 23 |
+
[](.)
|
| 24 |
+
[](.)
|
| 25 |
+
[](.)
|
| 26 |
+
[](.)
|
| 27 |
|
| 28 |
+
</div>
|
| 29 |
+
|
| 30 |
+
---
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
## Overview
|
| 33 |
+
|
| 34 |
+
**VT-DETR** stands for **Vietnamese Textbook Detection Transformer** β a fine-tuned variant of **RF-DETR Large** targeting automated detection of structural elements in Vietnamese textbook pages. It identifies four layout classes with high accuracy, enabling downstream document parsing, indexing, and educational content extraction pipelines.
|
| 35 |
+
|
| 36 |
+
| Property | Value |
|
| 37 |
+
|---|---|
|
| 38 |
+
| Base model | RF-DETR Large (pretrained) |
|
| 39 |
+
| Task | Object Detection |
|
| 40 |
+
| Domain | Document Layout / Textbook Pages |
|
| 41 |
+
| Language | Vietnamese |
|
| 42 |
+
| Input resolution | 640 Γ 640 |
|
| 43 |
+
|
| 44 |
+
---
|
| 45 |
+
|
| 46 |
+
## Classes
|
| 47 |
+
|
| 48 |
+
| ID | Label | Description |
|
| 49 |
+
|:---:|---|---|
|
| 50 |
+
| 0 | `Object-detection` | Generic detectable region |
|
| 51 |
+
| 1 | `Figure` | Diagrams, illustrations, charts |
|
| 52 |
+
| 2 | `Icon` | Small symbolic graphics |
|
| 53 |
+
| 3 | `Table` | Tabular data structures |
|
| 54 |
+
|
| 55 |
+
---
|
| 56 |
+
|
| 57 |
+
## Demo
|
| 58 |
+
|
| 59 |
+
| Input | Inference Output |
|
| 60 |
+
|:---:|:---:|
|
| 61 |
+
|  |  |
|
| 62 |
+
|
| 63 |
+
---
|
| 64 |
|
| 65 |
+
## Benchmark
|
| 66 |
|
| 67 |
+
### β
Best validation metrics
|
| 68 |
|
| 69 |
+
| Metric | Value |
|
| 70 |
+
|---|---:|
|
| 71 |
+
| mAP @ \[0.50 : 0.95\] | **0.8304** |
|
| 72 |
+
| mAP @ 0.50 | **0.9216** |
|
| 73 |
+
| mAP @ 0.75 | **0.8992** |
|
| 74 |
+
| Precision | **0.9471** |
|
| 75 |
+
| Recall | **0.8997** |
|
| 76 |
+
| F1 | **0.8875** |
|
| 77 |
+
|
| 78 |
+
### π Last epoch metrics
|
| 79 |
+
|
| 80 |
+
| Metric | Value |
|
| 81 |
+
|---|---:|
|
| 82 |
+
| mAP @ \[0.50 : 0.95\] | 0.8161 |
|
| 83 |
+
| mAP @ 0.50 | 0.9074 |
|
| 84 |
+
| mAP @ 0.75 | 0.8811 |
|
| 85 |
+
| Precision | 0.9184 |
|
| 86 |
+
| Recall | 0.8272 |
|
| 87 |
+
| F1 | 0.8694 |
|
| 88 |
+
|
| 89 |
+
> Metrics sourced from `outputs/rfdetr_textbook/metrics.csv` (full training run). A separate single-image eval run in `outputs/exp_rfdetr_textbook/eval/metrics.json` (`num_images=1`) is not representative and excluded from this report.
|
| 90 |
+
|
| 91 |
+
---
|
| 92 |
+
|
| 93 |
+
## Training Configuration
|
| 94 |
+
|
| 95 |
+
```yaml
|
| 96 |
+
model:
|
| 97 |
+
size: large
|
| 98 |
+
|
| 99 |
+
training:
|
| 100 |
+
epochs: 20
|
| 101 |
+
batch_size: 4
|
| 102 |
+
grad_accum_steps: 8
|
| 103 |
+
resolution: 640
|
| 104 |
+
device: cuda
|
| 105 |
+
|
| 106 |
+
augmentation:
|
| 107 |
+
mosaic: true
|
| 108 |
+
mixup: 0.1
|
| 109 |
+
|
| 110 |
+
early_stopping:
|
| 111 |
+
enabled: true
|
| 112 |
+
monitor: mAP50:95
|
| 113 |
+
patience_logs: 4
|
| 114 |
+
min_delta: 0.005
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
### Dataset split (COCO format)
|
| 118 |
+
|
| 119 |
+
```
|
| 120 |
+
data_resplit/
|
| 121 |
+
βββ train/
|
| 122 |
+
β βββ _annotations.coco.json
|
| 123 |
+
βββ valid/
|
| 124 |
+
β βββ _annotations.coco.json
|
| 125 |
+
βββ test/
|
| 126 |
+
βββ _annotations.coco.json
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
---
|
| 130 |
+
|
| 131 |
+
## Usage
|
| 132 |
+
|
| 133 |
+
### Install
|
| 134 |
+
|
| 135 |
+
```bash
|
| 136 |
+
pip install "rfdetr[train,loggers]"
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
### Inference
|
| 140 |
|
| 141 |
```python
|
| 142 |
+
from rfdetr import RFDETRLarge
|
|
|
|
| 143 |
from PIL import Image
|
|
|
|
| 144 |
|
| 145 |
+
model = RFDETRLarge(pretrain_weights="checkpoint_best_total.pth")
|
| 146 |
+
image = Image.open("page077.png")
|
| 147 |
+
detections = model.predict(image, threshold=0.5)
|
| 148 |
+
print(detections)
|
| 149 |
+
```
|
| 150 |
|
| 151 |
+
### Train
|
|
|
|
| 152 |
|
| 153 |
+
```bash
|
| 154 |
+
python -m rfdetr_finetune.train
|
| 155 |
+
```
|
| 156 |
|
| 157 |
+
### Evaluate
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
+
```bash
|
| 160 |
+
python -m rfdetr_finetune.evaluate
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
```
|
| 162 |
+
|
| 163 |
+
---
|
| 164 |
+
|
| 165 |
+
## Repository Structure
|
| 166 |
+
|
| 167 |
```
|
| 168 |
+
huggingface/
|
| 169 |
+
βββ README.md # Model card
|
| 170 |
+
βββ checkpoint_best_total.pth # Best checkpoint (by mAP50:95)
|
| 171 |
+
βββ inference.webp # Demo output
|
| 172 |
+
βββ page077.png # Demo input
|
|
|
|
|
|
|
|
|
|
| 173 |
```
|
| 174 |
|
| 175 |
+
---
|
| 176 |
+
|
| 177 |
+
## Limitations
|
| 178 |
+
|
| 179 |
+
- Trained and evaluated on Vietnamese textbook domain; generalization to other document types is not guaranteed.
|
| 180 |
+
- Test set benchmark not yet finalized β reported metrics are from the validation split.
|
| 181 |
+
- Robustness may be improved with additional data augmentation, larger datasets, or LR schedule tuning.
|
| 182 |
+
|
| 183 |
+
---
|
| 184 |
+
|
| 185 |
+
## License
|
| 186 |
+
|
| 187 |
+
This model is released under the **Apache License 2.0**, inherited from the base RF-DETR Large model by Roboflow.
|
| 188 |
+
|
| 189 |
+
> Copyright 2025 Roboflow, Inc.
|
| 190 |
+
> Licensed under the Apache License, Version 2.0. See [LICENSE](https://github.com/roboflow/rf-detr/blob/develop/LICENSE) for details.
|
| 191 |
+
|
| 192 |
+
Fine-tuned weights and additional code in this repository are also distributed under Apache 2.0.
|
| 193 |
+
|
| 194 |
+
---
|
| 195 |
+
|
| 196 |
+
## Citation
|
| 197 |
|
| 198 |
+
If you use this model or the RF-DETR framework, please cite:
|
| 199 |
|
| 200 |
+
**Base model (RF-DETR Large):**
|
| 201 |
|
| 202 |
```bibtex
|
| 203 |
+
@misc{rf-detr,
|
| 204 |
+
title = {RF-DETR: Neural Architecture Search for Real-Time Detection Transformers},
|
| 205 |
+
author = {Isaac Robinson and Peter Robicheaux and Matvei Popov and Deva Ramanan and Neehar Peri},
|
| 206 |
+
year = {2025},
|
| 207 |
+
eprint = {2511.09554},
|
| 208 |
+
archivePrefix= {arXiv},
|
| 209 |
+
primaryClass = {cs.CV},
|
| 210 |
+
url = {https://arxiv.org/abs/2511.09554}
|
| 211 |
}
|
| 212 |
```
|
| 213 |
|
| 214 |
+
> Base weights: [Roboflow/rf-detr-large](https://huggingface.co/Roboflow/rf-detr-large) β Apache 2.0
|
| 215 |
+
|
| 216 |
+
**This fine-tuned model (VT-DETR):**
|
| 217 |
+
|
| 218 |
+
```bibtex
|
| 219 |
+
@misc{vtdetr2025,
|
| 220 |
+
title = {VT-DETR: RF-DETR Large Fine-tuned for Textbook Layout Detection},
|
| 221 |
+
author = {hieptran318204},
|
| 222 |
+
year = {2025},
|
| 223 |
+
howpublished = {\url{https://huggingface.co/hieptran318204/vt-detr}}
|
| 224 |
+
}
|
| 225 |
+
```
|
| 226 |
+
|
| 227 |
+
---
|
| 228 |
+
|
| 229 |
+
<div align="center">
|
| 230 |
+
<sub>Fine-tuned with β€οΈ for Vietnamese educational document processing</sub>
|
| 231 |
+
</div>
|