Spaces:
Paused
Paused
File size: 1,736 Bytes
fdb3b99 526e9ad 8e8a34f 99edfce fdb3b99 526e9ad 99edfce 8e8a34f 99edfce 8e8a34f 526e9ad 8e8a34f | 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | ---
title: PaDoc
emoji: 📄
colorFrom: green
colorTo: gray
sdk: gradio
sdk_version: 6.22.0
app_file: app.py
python_version: "3.12"
startup_duration_timeout: 1h
short_description: Stream parallel document parsing with PaDoc
models:
- Longin-Yu/PaDoc
---
# PaDoc
This Space runs the Transformers parallel decoding path from
[PaDoc](https://github.com/Longin-Yu/Padoc) on ZeroGPU. It exposes only
lockstep-batched `parallel` execution: the main layout stream and every active
content branch advance together, bounded by eight concurrent branches.
The Gradio handler streams scheduler state, main tokens, branch content,
detected layout boxes, and the final JSON result as generation runs. It is the
ZeroGPU-compatible equivalent of:
```bash
CUDA_VISIBLE_DEVICES=0 padoc-transformers-serve \
--model Longin-Yu/PaDoc \
--device cuda:0 \
--execution-mode parallel \
--max-concurrent-branches 8
```
The Space uses direct PyTorch inference rather than starting the local FastAPI
server because ZeroGPU allocates a GPU only while the decorated Gradio request
is active.
## API
The streaming endpoint is named `/parse`:
```python
from gradio_client import Client, handle_file
client = Client("TonyZhan/PaDoc")
job = client.submit(
handle_file("document.png"),
"Parse this document.",
api_name="/parse",
)
for update in job:
print(update)
```
## Configuration
The defaults mirror the supported PaDoc dashboard path:
| Variable | Default |
| --- | ---: |
| `MODEL_ID` | `Longin-Yu/PaDoc` |
| `MAX_NEW_TOKENS` | `512` |
| `MAX_BRANCH_TOKENS` | `512` |
| `MAX_CONCURRENT_BRANCHES` | `8` |
| `MAX_TOTAL_BRANCHES` | `64` |
Model weights are licensed under
[CC-BY-NC-4.0](https://huggingface.co/Longin-Yu/PaDoc).
|