Add ONNX models for 1.1.0
Browse files- README.md +16 -14
- dewarp.onnx +3 -0
- gate.onnx +3 -0
- manifest.json +178 -0
- orient.onnx +3 -0
README.md
CHANGED
|
@@ -8,12 +8,13 @@ language:
|
|
| 8 |
tags:
|
| 9 |
- document-scanning
|
| 10 |
- document-dewarping
|
|
|
|
| 11 |
- pytorch
|
| 12 |
---
|
| 13 |
|
| 14 |
# Flattener
|
| 15 |
|
| 16 |
-
Version 1.
|
| 17 |
Flattener turns document photos and open books into flat, upright scans.
|
| 18 |
Processing runs locally.
|
| 19 |
|
|
@@ -21,33 +22,34 @@ Processing runs locally.
|
|
| 21 |
|
| 22 |
| File | Purpose |
|
| 23 |
|---|---|
|
| 24 |
-
| `dewarp.pt` | Correct page perspective and curvature |
|
| 25 |
-
| `gate.pt` | Detect the page region |
|
| 26 |
-
| `orient.pt` | Predict text orientation |
|
| 27 |
-
| `
|
|
|
|
| 28 |
|
| 29 |
-
The
|
| 30 |
-
The
|
|
|
|
|
|
|
| 31 |
|
| 32 |
## Use
|
| 33 |
|
| 34 |
-
From a Flattener 1.0.0 source checkout:
|
| 35 |
-
|
| 36 |
```bash
|
| 37 |
-
|
| 38 |
-
uv run python -m flattener.scan photo.jpg --out scans
|
| 39 |
```
|
| 40 |
|
| 41 |
-
The first scan downloads
|
| 42 |
Later scans reuse the local Hugging Face cache, including offline.
|
|
|
|
| 43 |
|
| 44 |
Download the files to a chosen directory with:
|
| 45 |
|
| 46 |
```bash
|
| 47 |
-
hf download DevWorld/flattener
|
| 48 |
```
|
| 49 |
|
| 50 |
-
Then pass `--bundle models/
|
| 51 |
|
| 52 |
## Training and use
|
| 53 |
|
|
|
|
| 8 |
tags:
|
| 9 |
- document-scanning
|
| 10 |
- document-dewarping
|
| 11 |
+
- onnx
|
| 12 |
- pytorch
|
| 13 |
---
|
| 14 |
|
| 15 |
# Flattener
|
| 16 |
|
| 17 |
+
Version 1.1.0 of the models for [Flattener](https://github.com/deveworld/flattener).
|
| 18 |
Flattener turns document photos and open books into flat, upright scans.
|
| 19 |
Processing runs locally.
|
| 20 |
|
|
|
|
| 22 |
|
| 23 |
| File | Purpose |
|
| 24 |
|---|---|
|
| 25 |
+
| `dewarp.onnx`, `dewarp.pt` | Correct page perspective and curvature |
|
| 26 |
+
| `gate.onnx`, `gate.pt` | Detect the page region |
|
| 27 |
+
| `orient.onnx`, `orient.pt` | Predict text orientation |
|
| 28 |
+
| `manifest.json` | Load the three ONNX models together |
|
| 29 |
+
| `bundle.json` | Load the three PyTorch checkpoints together |
|
| 30 |
|
| 31 |
+
The ONNX models are exported from the PyTorch checkpoints and hold the same weights.
|
| 32 |
+
The scanner runs them with ONNX Runtime on the CPU by default.
|
| 33 |
+
The PyTorch checkpoints run on a CUDA GPU and are the starting point for training.
|
| 34 |
+
`manifest.json` and the orientation checkpoint include the calibrated orientation temperature and threshold.
|
| 35 |
|
| 36 |
## Use
|
| 37 |
|
|
|
|
|
|
|
| 38 |
```bash
|
| 39 |
+
uvx flattener-scan -i photo.jpg scan.jpg
|
|
|
|
| 40 |
```
|
| 41 |
|
| 42 |
+
The first scan downloads the ONNX models at revision `1.1.0`.
|
| 43 |
Later scans reuse the local Hugging Face cache, including offline.
|
| 44 |
+
With PyTorch installed and a CUDA GPU present (`uvx --with torch flattener-scan ...`), the scanner downloads and uses the PyTorch checkpoints instead.
|
| 45 |
|
| 46 |
Download the files to a chosen directory with:
|
| 47 |
|
| 48 |
```bash
|
| 49 |
+
hf download DevWorld/flattener manifest.json dewarp.onnx gate.onnx orient.onnx --revision 1.1.0 --local-dir models
|
| 50 |
```
|
| 51 |
|
| 52 |
+
Then pass `--bundle models/manifest.json` to the scanner.
|
| 53 |
|
| 54 |
## Training and use
|
| 55 |
|
dewarp.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:34dae2641b43d1f6a7961b6842517e6d22f4115f711abcc9f0bc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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "flattener-web-bundle-1",
|
| 3 |
+
"version": "1.1.0",
|
| 4 |
+
"precision": "float32",
|
| 5 |
+
"opset": 18,
|
| 6 |
+
"models": {
|
| 7 |
+
"dewarp": {
|
| 8 |
+
"file": "dewarp.onnx",
|
| 9 |
+
"bytes": 31602437,
|
| 10 |
+
"inputs": {
|
| 11 |
+
"image": [
|
| 12 |
+
1,
|
| 13 |
+
3,
|
| 14 |
+
712,
|
| 15 |
+
488
|
| 16 |
+
]
|
| 17 |
+
},
|
| 18 |
+
"outputs": [
|
| 19 |
+
"grid"
|
| 20 |
+
],
|
| 21 |
+
"input_size": [
|
| 22 |
+
712,
|
| 23 |
+
488
|
| 24 |
+
],
|
| 25 |
+
"grid_size": [
|
| 26 |
+
45,
|
| 27 |
+
31
|
| 28 |
+
],
|
| 29 |
+
"grid_convention": "flattener",
|
| 30 |
+
"tta": "flip",
|
| 31 |
+
"model_config": {
|
| 32 |
+
"input_size": [
|
| 33 |
+
712,
|
| 34 |
+
488
|
| 35 |
+
],
|
| 36 |
+
"grid_size": [
|
| 37 |
+
45,
|
| 38 |
+
31
|
| 39 |
+
],
|
| 40 |
+
"num_filter": 32,
|
| 41 |
+
"kernel_size": 5,
|
| 42 |
+
"with_3d": true,
|
| 43 |
+
"grid_convention": "flattener",
|
| 44 |
+
"architecture": "uvdocnet"
|
| 45 |
+
}
|
| 46 |
+
},
|
| 47 |
+
"gate": {
|
| 48 |
+
"file": "gate.onnx",
|
| 49 |
+
"bytes": 2254621,
|
| 50 |
+
"inputs": {
|
| 51 |
+
"image": [
|
| 52 |
+
1,
|
| 53 |
+
3,
|
| 54 |
+
192,
|
| 55 |
+
144
|
| 56 |
+
]
|
| 57 |
+
},
|
| 58 |
+
"outputs": [
|
| 59 |
+
"probability"
|
| 60 |
+
],
|
| 61 |
+
"input_size": [
|
| 62 |
+
192,
|
| 63 |
+
144
|
| 64 |
+
],
|
| 65 |
+
"model_config": {
|
| 66 |
+
"input_size": [
|
| 67 |
+
192,
|
| 68 |
+
144
|
| 69 |
+
],
|
| 70 |
+
"channels": [
|
| 71 |
+
16,
|
| 72 |
+
32,
|
| 73 |
+
64,
|
| 74 |
+
128
|
| 75 |
+
],
|
| 76 |
+
"model_version": "region-context-unet-2.0"
|
| 77 |
+
}
|
| 78 |
+
},
|
| 79 |
+
"orient": {
|
| 80 |
+
"file": "orient.onnx",
|
| 81 |
+
"bytes": 1780334,
|
| 82 |
+
"inputs": {
|
| 83 |
+
"global_view": [
|
| 84 |
+
1,
|
| 85 |
+
1,
|
| 86 |
+
256,
|
| 87 |
+
256
|
| 88 |
+
],
|
| 89 |
+
"patches": [
|
| 90 |
+
1,
|
| 91 |
+
4,
|
| 92 |
+
1,
|
| 93 |
+
128,
|
| 94 |
+
128
|
| 95 |
+
]
|
| 96 |
+
},
|
| 97 |
+
"outputs": [
|
| 98 |
+
"logits",
|
| 99 |
+
"probabilities"
|
| 100 |
+
],
|
| 101 |
+
"config": {
|
| 102 |
+
"global_size": 256,
|
| 103 |
+
"patch_size": 128,
|
| 104 |
+
"patches": 4,
|
| 105 |
+
"page_long_side": 1024,
|
| 106 |
+
"energy_grid": 8,
|
| 107 |
+
"pad_value": 128,
|
| 108 |
+
"stem": 16,
|
| 109 |
+
"blocks": [
|
| 110 |
+
[
|
| 111 |
+
32,
|
| 112 |
+
1,
|
| 113 |
+
3,
|
| 114 |
+
false
|
| 115 |
+
],
|
| 116 |
+
[
|
| 117 |
+
48,
|
| 118 |
+
2,
|
| 119 |
+
3,
|
| 120 |
+
false
|
| 121 |
+
],
|
| 122 |
+
[
|
| 123 |
+
48,
|
| 124 |
+
1,
|
| 125 |
+
3,
|
| 126 |
+
false
|
| 127 |
+
],
|
| 128 |
+
[
|
| 129 |
+
96,
|
| 130 |
+
2,
|
| 131 |
+
3,
|
| 132 |
+
false
|
| 133 |
+
],
|
| 134 |
+
[
|
| 135 |
+
96,
|
| 136 |
+
1,
|
| 137 |
+
3,
|
| 138 |
+
false
|
| 139 |
+
],
|
| 140 |
+
[
|
| 141 |
+
192,
|
| 142 |
+
2,
|
| 143 |
+
5,
|
| 144 |
+
false
|
| 145 |
+
],
|
| 146 |
+
[
|
| 147 |
+
192,
|
| 148 |
+
1,
|
| 149 |
+
5,
|
| 150 |
+
false
|
| 151 |
+
],
|
| 152 |
+
[
|
| 153 |
+
192,
|
| 154 |
+
1,
|
| 155 |
+
5,
|
| 156 |
+
true
|
| 157 |
+
],
|
| 158 |
+
[
|
| 159 |
+
320,
|
| 160 |
+
2,
|
| 161 |
+
5,
|
| 162 |
+
true
|
| 163 |
+
],
|
| 164 |
+
[
|
| 165 |
+
320,
|
| 166 |
+
1,
|
| 167 |
+
5,
|
| 168 |
+
true
|
| 169 |
+
]
|
| 170 |
+
],
|
| 171 |
+
"hidden": 128,
|
| 172 |
+
"dropout": 0.1
|
| 173 |
+
},
|
| 174 |
+
"temperature": 0.5192675672115961,
|
| 175 |
+
"threshold": 0.9
|
| 176 |
+
}
|
| 177 |
+
}
|
| 178 |
+
}
|
orient.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9632f72031f8d54b4322110a4674f30a1a070d05e29843dcefb4dbbbe65aad69
|
| 3 |
+
size 1780334
|