Commit
Β·
90ace90
1
Parent(s):
2204718
Add DoTS.ocr to documentation with official --secrets syntax
Browse files
README.md
CHANGED
|
@@ -16,6 +16,7 @@ Run OCR on any dataset without needing your own GPU:
|
|
| 16 |
```bash
|
| 17 |
# Quick test with 10 samples
|
| 18 |
hf jobs uv run --flavor l4x1 \
|
|
|
|
| 19 |
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/nanonets-ocr.py \
|
| 20 |
your-input-dataset your-output-dataset \
|
| 21 |
--max-samples 10
|
|
@@ -71,6 +72,17 @@ Advanced reasoning-based OCR using [numind/NuMarkdown-8B-Thinking](https://huggi
|
|
| 71 |
- π **Multi-column Layouts** - Handles complex document structures
|
| 72 |
- β¨ **Thinking Traces** - Optional inclusion of reasoning process with `--include-thinking`
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
## π New Features
|
| 76 |
|
|
@@ -118,15 +130,24 @@ No GPU? No problem! Run on HF infrastructure:
|
|
| 118 |
```bash
|
| 119 |
# Basic OCR job
|
| 120 |
hf jobs uv run --flavor l4x1 \
|
|
|
|
| 121 |
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/nanonets-ocr.py \
|
| 122 |
your-input-dataset your-output-dataset
|
| 123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
# Real example with UFO dataset πΈ
|
| 126 |
hf jobs uv run \
|
| 127 |
--flavor a10g-large \
|
| 128 |
-
--
|
| 129 |
-
-s HF_TOKEN=$(python3 -c "from huggingface_hub import get_token; print(get_token())") \
|
| 130 |
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/nanonets-ocr.py \
|
| 131 |
davanstrien/ufo-ColPali \
|
| 132 |
your-username/ufo-ocr \
|
|
@@ -136,9 +157,8 @@ hf jobs uv run \
|
|
| 136 |
|
| 137 |
# NuMarkdown with reasoning traces for complex documents
|
| 138 |
hf jobs uv run \
|
| 139 |
-
--image vllm/vllm-openai:latest \
|
| 140 |
--flavor l4x4 \
|
| 141 |
-
|
| 142 |
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/numarkdown-ocr.py \
|
| 143 |
your-input-dataset your-output-dataset \
|
| 144 |
--max-samples 50 \
|
|
@@ -147,7 +167,7 @@ hf jobs uv run \
|
|
| 147 |
|
| 148 |
# Private dataset with custom settings
|
| 149 |
hf jobs uv run --flavor l40sx1 \
|
| 150 |
-
|
| 151 |
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/nanonets-ocr.py \
|
| 152 |
private-input private-output \
|
| 153 |
--private \
|
|
@@ -205,14 +225,18 @@ Any HuggingFace dataset containing images - documents, forms, receipts, books, h
|
|
| 205 |
| `--shuffle` | False | Shuffle dataset before processing |
|
| 206 |
| `--seed` | `42` | Random seed for shuffling |
|
| 207 |
|
| 208 |
-
*RolmOCR
|
| 209 |
**RolmOCR uses 16384/8192
|
| 210 |
|
| 211 |
-
###
|
| 212 |
|
|
|
|
| 213 |
- Output column is auto-generated from model name (e.g., `rolmocr_text`)
|
| 214 |
- Use `--output-column` to override the default name
|
| 215 |
|
| 216 |
-
|
|
|
|
|
|
|
|
|
|
| 217 |
|
| 218 |
-
|
|
|
|
| 16 |
```bash
|
| 17 |
# Quick test with 10 samples
|
| 18 |
hf jobs uv run --flavor l4x1 \
|
| 19 |
+
--secrets HF_TOKEN \
|
| 20 |
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/nanonets-ocr.py \
|
| 21 |
your-input-dataset your-output-dataset \
|
| 22 |
--max-samples 10
|
|
|
|
| 72 |
- π **Multi-column Layouts** - Handles complex document structures
|
| 73 |
- β¨ **Thinking Traces** - Optional inclusion of reasoning process with `--include-thinking`
|
| 74 |
|
| 75 |
+
### DoTS.ocr (`dots-ocr.py`)
|
| 76 |
+
|
| 77 |
+
Compact multilingual OCR using [rednote-hilab/dots.ocr](https://huggingface.co/rednote-hilab/dots.ocr) with only 1.7B parameters:
|
| 78 |
+
|
| 79 |
+
- π **100+ Languages** - Extensive multilingual support
|
| 80 |
+
- π **Simple OCR** - Clean text extraction (default mode)
|
| 81 |
+
- π **Layout Analysis** - Optional structured output with bboxes and categories
|
| 82 |
+
- π **Formula recognition** - LaTeX format support
|
| 83 |
+
- π― **Compact** - Only 1.7B parameters, efficient on smaller GPUs
|
| 84 |
+
- π **Flexible prompts** - Switch between OCR, layout-all, and layout-only modes
|
| 85 |
+
|
| 86 |
|
| 87 |
## π New Features
|
| 88 |
|
|
|
|
| 130 |
```bash
|
| 131 |
# Basic OCR job
|
| 132 |
hf jobs uv run --flavor l4x1 \
|
| 133 |
+
--secrets HF_TOKEN \
|
| 134 |
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/nanonets-ocr.py \
|
| 135 |
your-input-dataset your-output-dataset
|
| 136 |
|
| 137 |
+
# DoTS.ocr - Multilingual OCR with compact 1.7B model
|
| 138 |
+
hf jobs uv run --flavor a100-large \
|
| 139 |
+
--secrets HF_TOKEN \
|
| 140 |
+
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/dots-ocr.py \
|
| 141 |
+
davanstrien/ufo-ColPali \
|
| 142 |
+
your-username/ufo-ocr \
|
| 143 |
+
--batch-size 256 \
|
| 144 |
+
--max-samples 1000 \
|
| 145 |
+
--shuffle
|
| 146 |
|
| 147 |
# Real example with UFO dataset πΈ
|
| 148 |
hf jobs uv run \
|
| 149 |
--flavor a10g-large \
|
| 150 |
+
--secrets HF_TOKEN \
|
|
|
|
| 151 |
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/nanonets-ocr.py \
|
| 152 |
davanstrien/ufo-ColPali \
|
| 153 |
your-username/ufo-ocr \
|
|
|
|
| 157 |
|
| 158 |
# NuMarkdown with reasoning traces for complex documents
|
| 159 |
hf jobs uv run \
|
|
|
|
| 160 |
--flavor l4x4 \
|
| 161 |
+
--secrets HF_TOKEN \
|
| 162 |
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/numarkdown-ocr.py \
|
| 163 |
your-input-dataset your-output-dataset \
|
| 164 |
--max-samples 50 \
|
|
|
|
| 167 |
|
| 168 |
# Private dataset with custom settings
|
| 169 |
hf jobs uv run --flavor l40sx1 \
|
| 170 |
+
--secrets HF_TOKEN \
|
| 171 |
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/nanonets-ocr.py \
|
| 172 |
private-input private-output \
|
| 173 |
--private \
|
|
|
|
| 225 |
| `--shuffle` | False | Shuffle dataset before processing |
|
| 226 |
| `--seed` | `42` | Random seed for shuffling |
|
| 227 |
|
| 228 |
+
*RolmOCR and DoTS use batch size 16
|
| 229 |
**RolmOCR uses 16384/8192
|
| 230 |
|
| 231 |
+
### Script-Specific Options
|
| 232 |
|
| 233 |
+
**RolmOCR**:
|
| 234 |
- Output column is auto-generated from model name (e.g., `rolmocr_text`)
|
| 235 |
- Use `--output-column` to override the default name
|
| 236 |
|
| 237 |
+
**DoTS.ocr**:
|
| 238 |
+
- `--prompt-mode`: Choose `ocr` (default), `layout-all`, or `layout-only`
|
| 239 |
+
- `--custom-prompt`: Override with custom prompt text
|
| 240 |
+
- `--output-column`: Output column name (default: `markdown`)
|
| 241 |
|
| 242 |
+
π‘ **Performance tip**: Increase batch size for faster processing (e.g., `--batch-size 256` on A100)
|