File size: 1,576 Bytes
57a56c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
title: ScriptFlow
emoji: ✍️
colorFrom: indigo
colorTo: purple
sdk: gradio
sdk_version: "4.36.0"
app_file: app.py
pinned: false
license: mit
---

# ScriptFlow — Handwriting PDF → Word Document

Upload a handwritten PDF and get a clean `.docx` file back.

## Pipeline

| Step | Tool | Notes |
|------|------|-------|
| PDF → images | `pdftoppm` (Poppler) | 200 DPI PNG per page |
| Images → text | TrOCR (small or base) | HuggingFace `microsoft/trocr-*-handwritten` |
| Text → refined | T5 grammar correction | Optional — `vennify/t5-base-grammar-correction` |
| Text → .docx | python-docx | Page breaks at each PDF page |

## Deployment (your own Space)

1. Create a new Space on [huggingface.co/spaces](https://huggingface.co/spaces) — choose **Gradio**, **CPU basic** (free).
2. Upload all files from this folder:
   - `app.py`
   - `requirements.txt`
   - `packages.txt`
   - `README.md`
3. The Space builds automatically — first build takes ~3 min (installs torch CPU + packages).

## Expected speed (CPU free tier)

| Page count | OCR only | OCR + grammar |
|-----------|----------|---------------|
| 1 page | ~30–60 s | ~90–120 s |
| 5 pages | ~3–5 min | ~7–10 min |

> Models are cached after the first run within the same session, so subsequent uploads are faster.

## Tips

- Use **small** TrOCR model for speed; switch to **base** for denser/messier handwriting.
- Disable grammar correction for a faster raw OCR result — you can always clean up the `.docx` manually.
- Scans at ≥ 200 DPI give significantly better OCR accuracy.