Commit
Β·
3f59035
1
Parent(s):
43324c8
Remove dots-ocr from README due to compatibility issues
Browse filesThe script remains in the repository but is removed from documentation
until compatibility issues are resolved.
README.md
CHANGED
|
@@ -50,15 +50,6 @@ State-of-the-art document OCR using [nanonets/Nanonets-OCR-s](https://huggingfac
|
|
| 50 |
- πΌοΈ **Images** - Captions and descriptions included
|
| 51 |
- βοΈ **Forms** - Checkboxes rendered as β/β
|
| 52 |
|
| 53 |
-
### dots.ocr (`dots-ocr.py`)
|
| 54 |
-
|
| 55 |
-
Advanced document layout analysis and OCR using [rednote-hilab/dots.ocr](https://huggingface.co/rednote-hilab/dots.ocr) that provides:
|
| 56 |
-
|
| 57 |
-
- π― **Layout detection** - Bounding boxes for all document elements
|
| 58 |
-
- π **Category classification** - Text, Title, Table, Formula, Picture, etc.
|
| 59 |
-
- π **Reading order** - Preserves natural reading flow
|
| 60 |
-
- π **Multilingual support** - Handles multiple languages seamlessly
|
| 61 |
-
- π§ **Flexible output** - JSON, structured columns, or markdown
|
| 62 |
|
| 63 |
## π New Features
|
| 64 |
|
|
@@ -109,13 +100,6 @@ hf jobs uv run --flavor l4x1 \
|
|
| 109 |
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/nanonets-ocr.py \
|
| 110 |
your-input-dataset your-output-dataset
|
| 111 |
|
| 112 |
-
# Document layout analysis with dots.ocr
|
| 113 |
-
hf jobs uv run --flavor l4x1 \
|
| 114 |
-
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/dots-ocr.py \
|
| 115 |
-
your-input-dataset your-layout-dataset \
|
| 116 |
-
--mode layout-all \
|
| 117 |
-
--output-format structured \
|
| 118 |
-
--use-transformers # More compatible backend
|
| 119 |
|
| 120 |
# Real example with UFO dataset πΈ
|
| 121 |
hf jobs uv run \
|
|
@@ -166,10 +150,6 @@ uv run https://huggingface.co/datasets/uv-scripts/ocr/raw/main/nanonets-ocr.py \
|
|
| 166 |
uv run rolm-ocr.py documents extracted-text
|
| 167 |
uv run rolm-ocr.py images texts --shuffle --max-samples 100 # Random sample
|
| 168 |
|
| 169 |
-
# dots.ocr examples
|
| 170 |
-
uv run dots-ocr.py documents analyzed-docs # Full layout + OCR
|
| 171 |
-
uv run dots-ocr.py scans layouts --mode layout-only # Layout only
|
| 172 |
-
uv run dots-ocr.py papers markdown --output-format markdown # As markdown
|
| 173 |
```
|
| 174 |
|
| 175 |
## π Works With
|
|
@@ -184,8 +164,8 @@ Any HuggingFace dataset containing images - documents, forms, receipts, books, h
|
|
| 184 |
| -------------------------- | ------- | ----------------------------- |
|
| 185 |
| `--image-column` | `image` | Column containing images |
|
| 186 |
| `--batch-size` | `32`/`16`* | Images processed together |
|
| 187 |
-
| `--max-model-len` | `8192`/`16384
|
| 188 |
-
| `--max-tokens` | `4096`/`8192
|
| 189 |
| `--gpu-memory-utilization` | `0.8` | GPU memory usage (0.0-1.0) |
|
| 190 |
| `--split` | `train` | Dataset split to process |
|
| 191 |
| `--max-samples` | None | Limit samples (for testing) |
|
|
@@ -195,29 +175,12 @@ Any HuggingFace dataset containing images - documents, forms, receipts, books, h
|
|
| 195 |
|
| 196 |
*RolmOCR uses batch size 16
|
| 197 |
**RolmOCR uses 16384/8192
|
| 198 |
-
***dots.ocr uses 24000/16384
|
| 199 |
|
| 200 |
### RolmOCR Specific
|
| 201 |
|
| 202 |
- Output column is auto-generated from model name (e.g., `rolmocr_text`)
|
| 203 |
- Use `--output-column` to override the default name
|
| 204 |
|
| 205 |
-
### dots.ocr Specific Options
|
| 206 |
-
|
| 207 |
-
| Option | Default | Description |
|
| 208 |
-
| ------------------- | ------- | ------------------------------------- |
|
| 209 |
-
| `--mode` | `layout-all` | Processing mode: `layout-all`, `layout-only`, `ocr`, `grounding-ocr` |
|
| 210 |
-
| `--output-format` | `json` | Output format: `json`, `structured`, `markdown` |
|
| 211 |
-
| `--filter-category` | None | Filter by layout category (e.g., `Table`, `Formula`) |
|
| 212 |
-
| `--output-column` | `dots_ocr_output` | Column name for JSON output |
|
| 213 |
-
| `--bbox-column` | `layout_bboxes` | Column for bounding boxes (structured mode) |
|
| 214 |
-
| `--category-column` | `layout_categories` | Column for categories (structured mode) |
|
| 215 |
-
| `--text-column` | `layout_texts` | Column for texts (structured mode) |
|
| 216 |
-
| `--markdown-column` | `markdown` | Column for markdown output |
|
| 217 |
-
| `--use-transformers`| `False` | Use transformers backend instead of vLLM (more compatible) |
|
| 218 |
-
|
| 219 |
π‘ **Performance tip**: Increase batch size for faster processing (e.g., `--batch-size 128` for A10G GPUs)
|
| 220 |
|
| 221 |
-
β οΈ **dots.ocr Note**: If you encounter vLLM initialization errors, use `--use-transformers` for a more compatible (but slower) backend.
|
| 222 |
-
|
| 223 |
More OCR VLM Scripts coming soon! Stay tuned for updates!
|
|
|
|
| 50 |
- πΌοΈ **Images** - Captions and descriptions included
|
| 51 |
- βοΈ **Forms** - Checkboxes rendered as β/β
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
## π New Features
|
| 55 |
|
|
|
|
| 100 |
https://huggingface.co/datasets/uv-scripts/ocr/raw/main/nanonets-ocr.py \
|
| 101 |
your-input-dataset your-output-dataset
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
# Real example with UFO dataset πΈ
|
| 105 |
hf jobs uv run \
|
|
|
|
| 150 |
uv run rolm-ocr.py documents extracted-text
|
| 151 |
uv run rolm-ocr.py images texts --shuffle --max-samples 100 # Random sample
|
| 152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
```
|
| 154 |
|
| 155 |
## π Works With
|
|
|
|
| 164 |
| -------------------------- | ------- | ----------------------------- |
|
| 165 |
| `--image-column` | `image` | Column containing images |
|
| 166 |
| `--batch-size` | `32`/`16`* | Images processed together |
|
| 167 |
+
| `--max-model-len` | `8192`/`16384`** | Max context length |
|
| 168 |
+
| `--max-tokens` | `4096`/`8192`** | Max output tokens |
|
| 169 |
| `--gpu-memory-utilization` | `0.8` | GPU memory usage (0.0-1.0) |
|
| 170 |
| `--split` | `train` | Dataset split to process |
|
| 171 |
| `--max-samples` | None | Limit samples (for testing) |
|
|
|
|
| 175 |
|
| 176 |
*RolmOCR uses batch size 16
|
| 177 |
**RolmOCR uses 16384/8192
|
|
|
|
| 178 |
|
| 179 |
### RolmOCR Specific
|
| 180 |
|
| 181 |
- Output column is auto-generated from model name (e.g., `rolmocr_text`)
|
| 182 |
- Use `--output-column` to override the default name
|
| 183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
π‘ **Performance tip**: Increase batch size for faster processing (e.g., `--batch-size 128` for A10G GPUs)
|
| 185 |
|
|
|
|
|
|
|
| 186 |
More OCR VLM Scripts coming soon! Stay tuned for updates!
|