wormocr 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. wormocr/__init__.py +18 -0
  2. wormocr/__main__.py +4 -0
  3. wormocr/api.py +229 -0
  4. wormocr/benchmark/__init__.py +5 -0
  5. wormocr/benchmark/report.py +403 -0
  6. wormocr/checkpoints.py +55 -0
  7. wormocr/cli.py +308 -0
  8. wormocr/config.py +220 -0
  9. wormocr/data/__init__.py +5 -0
  10. wormocr/data/dataset.py +110 -0
  11. wormocr/data/fonts.py +173 -0
  12. wormocr/data/handwriting.py +304 -0
  13. wormocr/data/lexicon.py +105 -0
  14. wormocr/data/lexicon_medical.py +48 -0
  15. wormocr/data/mixed.py +211 -0
  16. wormocr/data/synthetic.py +445 -0
  17. wormocr/detection/__init__.py +5 -0
  18. wormocr/detection/lines.py +382 -0
  19. wormocr/evaluation/__init__.py +5 -0
  20. wormocr/evaluation/errors.py +145 -0
  21. wormocr/evaluation/metrics.py +105 -0
  22. wormocr/evaluation/robustness.py +43 -0
  23. wormocr/exceptions.py +25 -0
  24. wormocr/export/__init__.py +5 -0
  25. wormocr/export/onnx_export.py +75 -0
  26. wormocr/hub.py +157 -0
  27. wormocr/inference/__init__.py +5 -0
  28. wormocr/inference/decode.py +113 -0
  29. wormocr/inference/engine.py +122 -0
  30. wormocr/models/__init__.py +5 -0
  31. wormocr/models/crnn.py +236 -0
  32. wormocr/preprocessing.py +135 -0
  33. wormocr/py.typed +0 -0
  34. wormocr/runtime.py +56 -0
  35. wormocr/training/__init__.py +5 -0
  36. wormocr/training/loop.py +645 -0
  37. wormocr/vocabulary.py +69 -0
  38. wormocr/web/__init__.py +5 -0
  39. wormocr/web/server.py +505 -0
  40. wormocr/web/static/app.js +514 -0
  41. wormocr/web/static/index.html +141 -0
  42. wormocr/web/static/style.css +379 -0
  43. wormocr-1.0.0.dist-info/METADATA +377 -0
  44. wormocr-1.0.0.dist-info/RECORD +48 -0
  45. wormocr-1.0.0.dist-info/WHEEL +5 -0
  46. wormocr-1.0.0.dist-info/entry_points.txt +2 -0
  47. wormocr-1.0.0.dist-info/licenses/LICENSE +21 -0
  48. wormocr-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,379 @@
1
+ :root {
2
+ --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
3
+ --mono: "JetBrains Mono", "Cascadia Mono", "SF Mono", Consolas, monospace;
4
+ --topbar: 52px;
5
+ --statusbar: 30px;
6
+ --side: clamp(300px, 36vw, 520px);
7
+ }
8
+
9
+ [data-theme="light"] {
10
+ --bg: #ffffff;
11
+ --bg-sub: #f7f7f8;
12
+ --bg-hover: #f0f0f2;
13
+ --line: #e6e6e9;
14
+ --line-strong: #d4d4d8;
15
+ --text: #18181b;
16
+ --muted: #71717a;
17
+ --faint: #a1a1aa;
18
+ --accent: #2563eb;
19
+ --accent-bg: #eff4ff;
20
+ --mid: #b45309;
21
+ --mid-bg: #fef6e7;
22
+ --low: #dc2626;
23
+ --low-bg: #fdecec;
24
+ --ok: #16a34a;
25
+ --canvas: #f2f2f4;
26
+ }
27
+
28
+ [data-theme="dark"] {
29
+ --bg: #111113;
30
+ --bg-sub: #18181b;
31
+ --bg-hover: #222226;
32
+ --line: #27272a;
33
+ --line-strong: #3f3f46;
34
+ --text: #ececef;
35
+ --muted: #a1a1aa;
36
+ --faint: #6b6b74;
37
+ --accent: #60a5fa;
38
+ --accent-bg: #172036;
39
+ --mid: #f59e0b;
40
+ --mid-bg: #2a2010;
41
+ --low: #f87171;
42
+ --low-bg: #2c1515;
43
+ --ok: #4ade80;
44
+ --canvas: #0b0b0d;
45
+ }
46
+
47
+ * { box-sizing: border-box; }
48
+ [hidden] { display: none !important; }
49
+
50
+ html, body { height: 100%; overflow: hidden; }
51
+ body {
52
+ margin: 0;
53
+ display: grid;
54
+ grid-template-rows: var(--topbar) minmax(0, 1fr) var(--statusbar);
55
+ font: 13px/1.5 var(--font);
56
+ color: var(--text);
57
+ background: var(--bg);
58
+ -webkit-font-smoothing: antialiased;
59
+ }
60
+ button, input { font: inherit; color: inherit; }
61
+ svg { width: 16px; height: 16px; flex-shrink: 0; }
62
+ kbd { font: 11px var(--mono); padding: 0 4px; border: 1px solid var(--line-strong); border-radius: 4px; }
63
+ .muted { color: var(--muted); }
64
+ .small { font-size: 12px; }
65
+ .spacer { flex: 1; }
66
+
67
+ /* ---------- Controls ---------- */
68
+ .btn {
69
+ height: 30px;
70
+ padding: 0 12px;
71
+ border: 1px solid var(--line-strong);
72
+ border-radius: 6px;
73
+ background: var(--bg);
74
+ font-weight: 500;
75
+ cursor: pointer;
76
+ white-space: nowrap;
77
+ }
78
+ .btn:hover:not(:disabled) { background: var(--bg-hover); }
79
+ .btn:disabled { color: var(--faint); cursor: default; }
80
+ .btn.solid { background: var(--text); border-color: var(--text); color: var(--bg); }
81
+ .btn.solid:hover { opacity: 0.88; background: var(--text); }
82
+ .btn.small { height: 26px; padding: 0 9px; font-size: 12px; }
83
+
84
+ .icon {
85
+ display: inline-grid;
86
+ place-items: center;
87
+ width: 30px;
88
+ height: 30px;
89
+ border: 0;
90
+ border-radius: 6px;
91
+ background: transparent;
92
+ color: var(--muted);
93
+ cursor: pointer;
94
+ }
95
+ .icon:hover { background: var(--bg-hover); color: var(--text); }
96
+ .icon.small { width: 24px; height: 24px; font-size: 15px; }
97
+
98
+ .link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 4px; }
99
+ .link:hover { text-decoration: underline; }
100
+
101
+ .check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; user-select: none; }
102
+ .check input { margin: 0; accent-color: var(--accent); }
103
+
104
+ .segmented { display: inline-flex; padding: 2px; border: 1px solid var(--line-strong); border-radius: 7px; }
105
+ .segmented button {
106
+ height: 24px;
107
+ padding: 0 11px;
108
+ border: 0;
109
+ border-radius: 5px;
110
+ background: transparent;
111
+ color: var(--muted);
112
+ font-weight: 500;
113
+ cursor: pointer;
114
+ }
115
+ .segmented button[aria-checked="true"] { background: var(--bg-hover); color: var(--text); }
116
+
117
+ /* ---------- Top bar ---------- */
118
+ .topbar {
119
+ position: relative;
120
+ display: flex;
121
+ align-items: center;
122
+ justify-content: space-between;
123
+ gap: 16px;
124
+ padding: 0 14px;
125
+ border-bottom: 1px solid var(--line);
126
+ min-width: 0;
127
+ }
128
+ .topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
129
+ .brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 14px; color: var(--text); text-decoration: none; }
130
+ .brand svg { width: 18px; height: 18px; }
131
+ .file { display: flex; align-items: baseline; gap: 8px; min-width: 0; padding-left: 12px; border-left: 1px solid var(--line); }
132
+ .file-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 32vw; }
133
+ .file-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
134
+ .divider { width: 1px; height: 20px; background: var(--line); }
135
+
136
+ .progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
137
+ .progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.25s ease, opacity 0.4s ease; }
138
+ .progress div.complete { opacity: 0; }
139
+
140
+ /* ---------- Workspace ---------- */
141
+ .workspace {
142
+ display: grid;
143
+ grid-template-columns: minmax(0, 1fr) var(--side);
144
+ grid-template-rows: minmax(0, 1fr) minmax(0, 0.62fr);
145
+ min-height: 0;
146
+ }
147
+ .pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
148
+ .doc-pane { grid-row: 1 / span 2; border-right: 1px solid var(--line); }
149
+ .log-pane { border-top: 1px solid var(--line); }
150
+
151
+ .pane-head {
152
+ display: flex;
153
+ align-items: center;
154
+ gap: 10px;
155
+ height: 40px;
156
+ padding: 0 12px;
157
+ border-bottom: 1px solid var(--line);
158
+ flex-shrink: 0;
159
+ }
160
+ .pane-title { font-weight: 600; }
161
+ .pane-body { flex: 1; min-height: 0; overflow: auto; }
162
+
163
+ /* ---------- Document ---------- */
164
+ .doc-body { background: var(--canvas); position: relative; }
165
+ .empty {
166
+ position: absolute;
167
+ inset: 0;
168
+ display: flex;
169
+ flex-direction: column;
170
+ align-items: center;
171
+ justify-content: center;
172
+ gap: 10px;
173
+ padding: 24px;
174
+ }
175
+ .drop {
176
+ width: min(460px, 100%);
177
+ padding: 36px 24px;
178
+ display: flex;
179
+ flex-direction: column;
180
+ align-items: center;
181
+ gap: 6px;
182
+ text-align: center;
183
+ border: 1px dashed var(--line-strong);
184
+ border-radius: 10px;
185
+ background: var(--bg);
186
+ color: var(--muted);
187
+ cursor: pointer;
188
+ transition: border-color 0.15s, background 0.15s;
189
+ }
190
+ .drop svg { width: 26px; height: 26px; color: var(--text); margin-bottom: 4px; }
191
+ .drop strong { color: var(--text); font-size: 15px; font-weight: 600; }
192
+ .drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-bg); }
193
+
194
+ .pages { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 18px; }
195
+ .page { width: 100%; }
196
+ .page-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
197
+ .sheet { position: relative; line-height: 0; background: #fff; border: 1px solid var(--line); }
198
+ .sheet img { display: block; width: 100%; height: auto; }
199
+ .boxes { position: absolute; inset: 0; }
200
+ .boxes.off { display: none; }
201
+ .box {
202
+ position: absolute;
203
+ border: 1px dashed rgba(113, 113, 122, 0.55);
204
+ cursor: pointer;
205
+ }
206
+ .box.done { border: 1px solid rgba(37, 99, 235, 0.55); background: rgba(37, 99, 235, 0.05); }
207
+ .box.done.mid { border-color: rgba(180, 83, 9, 0.75); background: rgba(245, 158, 11, 0.08); }
208
+ .box.done.low { border-color: rgba(220, 38, 38, 0.8); background: rgba(220, 38, 38, 0.08); }
209
+ .box.current { border: 1px solid var(--accent); background: rgba(37, 99, 235, 0.12); }
210
+ .box.active { outline: 2px solid var(--accent); outline-offset: 1px; background: rgba(37, 99, 235, 0.14); }
211
+
212
+ .zoom { display: flex; align-items: center; gap: 2px; }
213
+ .zoom span { min-width: 40px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
214
+
215
+ /* ---------- Results ---------- */
216
+ .tabs { display: flex; gap: 2px; }
217
+ .tabs button {
218
+ height: 28px;
219
+ padding: 0 10px;
220
+ border: 0;
221
+ border-radius: 6px;
222
+ background: transparent;
223
+ color: var(--muted);
224
+ font-weight: 500;
225
+ white-space: nowrap;
226
+ cursor: pointer;
227
+ }
228
+ .tabs button:hover { color: var(--text); }
229
+ .tabs button[aria-selected="true"] { color: var(--text); background: var(--bg-hover); }
230
+ .count { color: var(--faint); font-variant-numeric: tabular-nums; margin-left: 2px; }
231
+
232
+ .summary { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); flex-shrink: 0; }
233
+ .summary div { padding: 7px 12px; border-right: 1px solid var(--line); min-width: 0; }
234
+ .summary div:last-child { border-right: 0; }
235
+ .summary span { display: block; font-size: 11px; color: var(--muted); }
236
+ .summary b { display: block; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
237
+
238
+ .placeholder { margin: 0; padding: 24px 16px; color: var(--faint); text-align: center; }
239
+
240
+ .text-view { font: 12px/1.6 var(--mono); padding-bottom: 12px; }
241
+ .text-page-head {
242
+ position: sticky;
243
+ top: 0;
244
+ z-index: 1;
245
+ padding: 6px 12px;
246
+ font: 600 11px var(--font);
247
+ color: var(--muted);
248
+ background: var(--bg-sub);
249
+ border-bottom: 1px solid var(--line);
250
+ }
251
+ .tl { display: grid; grid-template-columns: 38px minmax(0, 1fr); padding-right: 12px; cursor: pointer; }
252
+ .tl:hover { background: var(--bg-hover); }
253
+ .tl.active { background: var(--accent-bg); }
254
+ .tl .n { color: var(--faint); text-align: right; padding-right: 12px; user-select: none; }
255
+ .tl .t { white-space: pre-wrap; overflow-wrap: anywhere; }
256
+ .tl.mid .t { background: var(--mid-bg); }
257
+ .tl.low .t { background: var(--low-bg); }
258
+
259
+ table.lines { width: 100%; border-collapse: collapse; table-layout: fixed; }
260
+ table.lines th {
261
+ position: sticky;
262
+ top: 0;
263
+ z-index: 1;
264
+ text-align: left;
265
+ font-weight: 500;
266
+ font-size: 11px;
267
+ color: var(--muted);
268
+ padding: 6px 8px;
269
+ background: var(--bg-sub);
270
+ border-bottom: 1px solid var(--line);
271
+ }
272
+ table.lines th:nth-child(1), table.lines th:nth-child(2) { width: 34px; }
273
+ table.lines th:nth-child(4) { width: 62px; }
274
+ table.lines th:nth-child(5) { width: 50px; }
275
+ table.lines td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
276
+ table.lines td.t { font: 12px var(--mono); overflow-wrap: anywhere; }
277
+ table.lines td.n { color: var(--muted); font-variant-numeric: tabular-nums; }
278
+ table.lines td.mid { color: var(--mid); }
279
+ table.lines td.low { color: var(--low); }
280
+ table.lines tr { cursor: pointer; }
281
+ table.lines tbody tr:hover { background: var(--bg-hover); }
282
+ table.lines tr.active { background: var(--accent-bg); }
283
+
284
+ .json { margin: 0; padding: 12px; font: 11.5px/1.55 var(--mono); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
285
+
286
+ /* ---------- Activity log ---------- */
287
+ .live { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
288
+ .live.on { background: var(--ok); }
289
+ .log { list-style: none; margin: 0; padding: 6px 0; font: 11px/1.6 var(--mono); }
290
+ .log li { display: grid; grid-template-columns: 46px 62px minmax(0, 1fr); gap: 6px; padding: 1px 10px; }
291
+ .log li:hover { background: var(--bg-sub); }
292
+ .log .ts { color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }
293
+ .log .tag { color: var(--muted); }
294
+ .log .msg { overflow-wrap: anywhere; }
295
+ .log .ms { color: var(--faint); }
296
+ .log li.line .msg { color: var(--muted); }
297
+ .log li.warn .msg { color: var(--mid); }
298
+ .log li.error .tag, .log li.error .msg { color: var(--low); }
299
+ .log li.done .msg { color: var(--ok); }
300
+ .log .log-idle { display: block; color: var(--faint); }
301
+ .log.hide-lines li.line { display: none; }
302
+
303
+ /* ---------- Status bar ---------- */
304
+ .statusbar {
305
+ display: flex;
306
+ align-items: center;
307
+ gap: 16px;
308
+ padding: 0 14px;
309
+ border-top: 1px solid var(--line);
310
+ background: var(--bg-sub);
311
+ font-size: 12px;
312
+ color: var(--muted);
313
+ white-space: nowrap;
314
+ overflow: hidden;
315
+ }
316
+ .steps { display: flex; gap: 14px; list-style: none; margin: 0; padding: 0; }
317
+ .steps li { display: flex; align-items: center; gap: 6px; color: var(--faint); }
318
+ .steps li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
319
+ .steps li.active { color: var(--text); }
320
+ .steps li.active::before { background: var(--accent); animation: blink 1s ease-in-out infinite; }
321
+ .steps li.done { color: var(--muted); }
322
+ .steps li.done::before { background: var(--ok); }
323
+ .steps li.error { color: var(--low); }
324
+ .steps li.error::before { background: var(--low); }
325
+ .timings { color: var(--faint); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
326
+ .model { display: flex; align-items: center; gap: 6px; }
327
+ .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
328
+ .dot.ok { background: var(--ok); }
329
+ .dot.bad { background: var(--low); }
330
+
331
+ /* ---------- Overlays ---------- */
332
+ .veil {
333
+ position: fixed;
334
+ inset: 0;
335
+ z-index: 50;
336
+ display: grid;
337
+ place-items: center;
338
+ background: color-mix(in srgb, var(--bg) 80%, transparent);
339
+ }
340
+ .veil div { padding: 28px 40px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--bg); font-weight: 600; font-size: 15px; }
341
+
342
+ .toast {
343
+ position: fixed;
344
+ right: 16px;
345
+ bottom: calc(var(--statusbar) + 12px);
346
+ z-index: 60;
347
+ max-width: 420px;
348
+ padding: 8px 12px;
349
+ border: 1px solid var(--line-strong);
350
+ border-radius: 6px;
351
+ background: var(--bg);
352
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
353
+ opacity: 0;
354
+ transform: translateY(6px);
355
+ transition: opacity 0.2s, transform 0.2s;
356
+ pointer-events: none;
357
+ }
358
+ .toast.show { opacity: 1; transform: none; }
359
+ .toast.error { border-color: var(--low); color: var(--low); }
360
+
361
+ @keyframes blink { 50% { opacity: 0.35; } }
362
+ @media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
363
+
364
+ /* ---------- Narrow screens: stack panes, still no page scroll ---------- */
365
+ @media (max-width: 980px) {
366
+ .file-meta, .timings { display: none; }
367
+ .summary div { padding: 6px 10px; }
368
+ }
369
+
370
+ @media (max-width: 680px) {
371
+ :root { --side: 1fr; }
372
+ .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 0.6fr); }
373
+ .doc-pane { grid-row: auto; border-right: 0; }
374
+ .result-pane { border-top: 1px solid var(--line); }
375
+ .file, .divider, .timings { display: none; }
376
+ .topbar { gap: 8px; padding: 0 8px; }
377
+ .topbar-right { gap: 6px; }
378
+ #rerun-button { display: none; }
379
+ }