Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: afl-3.0
|
| 3 |
+
pipeline_tag: image-to-text
|
| 4 |
+
tags:
|
| 5 |
+
- math
|
| 6 |
+
- ocr
|
| 7 |
+
- handwriting
|
| 8 |
+
- trocr
|
| 9 |
+
- gguf
|
| 10 |
+
- crispembed
|
| 11 |
+
base_model: fhswf/TrOCR_Math_handwritten
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# TrOCR Math Handwritten — GGUF
|
| 15 |
+
|
| 16 |
+
Handwritten math equation recognition via [CrispEmbed](https://github.com/CrispStrobe/CrispEmbed)'s ggml inference engine.
|
| 17 |
+
|
| 18 |
+
**Source model**: [fhswf/TrOCR_Math_handwritten](https://huggingface.co/fhswf/TrOCR_Math_handwritten) (AFL-3.0)
|
| 19 |
+
|
| 20 |
+
**Architecture**: ViT-Large encoder (24L, 1024d, 16H) + TrOCR-Large decoder (12L, 1024d, 16H, vocab=50265)
|
| 21 |
+
|
| 22 |
+
## Models
|
| 23 |
+
|
| 24 |
+
| File | Size | Description |
|
| 25 |
+
|------|------|-------------|
|
| 26 |
+
| `trocr-math-handwritten-fp16.gguf` | 1.2 GB | FP16 weights |
|
| 27 |
+
| `trocr-math-handwritten-q4_k.gguf` | 355 MB | Q4_K quantized |
|
| 28 |
+
|
| 29 |
+
## Verified Output
|
| 30 |
+
|
| 31 |
+
| Input | Recognized |
|
| 32 |
+
|-------|-----------|
|
| 33 |
+
| x+y=5 (hand-drawn) | `X + Y =` |
|
| 34 |
+
| x²+1 (printed) | `x^{2}` |
|
| 35 |
+
| 3x+7=0 (printed) | `3x+7` |
|
| 36 |
+
| + (cross pattern) | `+` |
|
| 37 |
+
|
| 38 |
+
## Usage with CrispEmbed
|
| 39 |
+
|
| 40 |
+
```c
|
| 41 |
+
math_ocr_context* ctx = math_ocr_init("trocr-math-handwritten-q4_k.gguf", 4);
|
| 42 |
+
const char* latex = math_ocr_recognize(ctx, gray_pixels, width, height, &len);
|
| 43 |
+
math_ocr_free(ctx);
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
## Conversion
|
| 47 |
+
|
| 48 |
+
Converted from HuggingFace safetensors using CrispEmbed's torch-free converter:
|
| 49 |
+
|
| 50 |
+
```bash
|
| 51 |
+
python models/convert-trocr-safetensors-to-gguf.py \
|
| 52 |
+
--model-dir /path/to/fhswf/TrOCR_Math_handwritten \
|
| 53 |
+
--output trocr-math-handwritten-fp16.gguf --fp16
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
Key converter features:
|
| 57 |
+
- No PyTorch dependency (uses `safetensors` + `gguf` + `numpy` only)
|
| 58 |
+
- Generates sinusoidal position embeddings (not stored in checkpoint)
|
| 59 |
+
- Squeezes 3D batch dimensions, reshapes 4D conv weights
|
| 60 |
+
- Preserves AFL-3.0 license in GGUF metadata
|
| 61 |
+
|
| 62 |
+
## License
|
| 63 |
+
|
| 64 |
+
Academic Free License v3.0 (inherited from source model)
|