@qvac/ocr-ggml 0.25.1 → 0.26.1
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.
- package/README.md +3 -3
- package/index.d.ts +2 -2
- package/index.js +13 -16
- package/package.json +4 -2
- package/prebuilds/android-arm64/qvac__ocr-ggml.bare +0 -0
- package/prebuilds/darwin-arm64/qvac__ocr-ggml.bare +0 -0
- package/prebuilds/darwin-arm64/qvac__ocr-ggml.bare.exports +1 -1
- package/prebuilds/darwin-x64/qvac__ocr-ggml.bare +0 -0
- package/prebuilds/darwin-x64/qvac__ocr-ggml.bare.exports +1 -1
- package/prebuilds/ios-arm64/qvac__ocr-ggml.bare +0 -0
- package/prebuilds/ios-arm64/qvac__ocr-ggml.bare.exports +1 -1
- package/prebuilds/ios-arm64-simulator/qvac__ocr-ggml.bare +0 -0
- package/prebuilds/ios-arm64-simulator/qvac__ocr-ggml.bare.exports +1 -1
- package/prebuilds/ios-x64-simulator/qvac__ocr-ggml.bare +0 -0
- package/prebuilds/ios-x64-simulator/qvac__ocr-ggml.bare.exports +1 -1
- package/prebuilds/linux-arm64/qvac__ocr-ggml.bare +0 -0
- package/prebuilds/linux-x64/qvac__ocr-ggml.bare +0 -0
- package/prebuilds/win32-x64/qvac__ocr-ggml.bare +0 -0
- package/test/integration/backend-device.test.js +13 -5
package/README.md
CHANGED
|
@@ -149,7 +149,7 @@ bare examples/backend-device.js --backend metal
|
|
|
149
149
|
| `params.lowConfidenceThreshold` | `number` | | `0.4` | retry threshold (`easyocr` only) |
|
|
150
150
|
| `params.recognizerBatchSize` | `number` | | `32` | recognizer batch size (`easyocr` only) |
|
|
151
151
|
| `params.nThreads` | `number` | | `0` (auto) | CPU thread count for GGML; `<0` leaves the GGML default |
|
|
152
|
-
| `params.backendsDir` | `string` | |
|
|
152
|
+
| `params.backendsDir` | `string` | | fabric backends root | directory holding `libqvac-ggml-*.so` backend shared libs. On desktop, the root `@qvac/fabric/backends` resolves; on mobile, this package's `prebuilds/` |
|
|
153
153
|
| `params.backendDevice` | `'cpu'` \| `'vulkan'` \| `'metal'` \| `'opencl'` | | `'cpu'` | ggml backend device. `'vulkan'` (Linux/Windows/Android), `'metal'` (Apple) and `'opencl'` (Android/Adreno) opt in to GPU inference with transparent CPU fallback — see [Backend device](#backend-device-cpu--vulkan--metal--opencl) |
|
|
154
154
|
| `params.main-gpu` / `params.main_gpu` | `number` \| `string` | | _prefer dedicated_ | Raw ggml registry index or strict GPU class; requires GPU `backendDevice`. See below. |
|
|
155
155
|
| `params.gpuDevice` | `number` | | _prefer discrete_ | 0-based index into the matching GPU/iGPU devices for `'vulkan'`/`'metal'`/`'opencl'`; out-of-range → CPU fallback — see [Selecting a specific GPU](#selecting-a-specific-gpu-gpudevice) |
|
|
@@ -234,7 +234,7 @@ Behaviour and expectations:
|
|
|
234
234
|
`backendIsGpu` stat). It never silently does the wrong thing.
|
|
235
235
|
- **Required backend libs.** Vulkan execution needs the `libggml-vulkan`
|
|
236
236
|
backend shared library (`libggml-vulkan.so` / `.dll` / `.dylib`) present in
|
|
237
|
-
`backendsDir` (
|
|
237
|
+
`backendsDir` (on desktop, the root `@qvac/fabric/backends` resolves; on mobile, this package's `prebuilds/<target>/`), plus a working
|
|
238
238
|
Vulkan driver/ICD and a Vulkan-capable GPU on the host. **OpenCL** likewise
|
|
239
239
|
needs the `libggml-opencl` backend shared library plus a working OpenCL
|
|
240
240
|
runtime (`libOpenCL.so`); it is built primarily for **Android** (the `opencl`
|
|
@@ -667,7 +667,7 @@ omission for v1: `--debug-png` (annotated overlay) — print boxes via
|
|
|
667
667
|
|
|
668
668
|
| Script | Purpose |
|
|
669
669
|
|---|---|
|
|
670
|
-
| [`scripts/check_ggml_backends.sh`](./scripts/check_ggml_backends.sh) | Probe shipped ggml backends + BLAS/Vulkan/OpenCL paths in `
|
|
670
|
+
| [`scripts/check_ggml_backends.sh`](./scripts/check_ggml_backends.sh) | Probe shipped ggml backends + BLAS/Vulkan/OpenCL paths in the installed `@qvac/fabric` runtime |
|
|
671
671
|
| [`scripts/pth_to_gguf.py`](./scripts/pth_to_gguf.py) | Weight converter: EasyOCR PyTorch `.pth` → `.gguf` (optionally `Q8_0` / `Q4_K` quantized) |
|
|
672
672
|
| [`scripts/convert-model.sh`](./scripts/convert-model.sh) | Wrapper around the converter (`npm run convert-model`) — venv discovery, sanity checks |
|
|
673
673
|
| [`scripts/setup-venv.sh`](./scripts/setup-venv.sh) | One-time provisioning of the converter venv (`npm run setup:venv`) |
|
package/index.d.ts
CHANGED
|
@@ -59,8 +59,8 @@ export interface OcrGgmlParams {
|
|
|
59
59
|
*/
|
|
60
60
|
nThreads?: number;
|
|
61
61
|
/**
|
|
62
|
-
* Directory holding ggml backend shared libraries. Default:
|
|
63
|
-
* `
|
|
62
|
+
* Directory holding ggml backend shared libraries. Default: the root
|
|
63
|
+
* `@qvac/fabric/backends` resolves (desktop), falling back to this package's `prebuilds/` on
|
|
64
64
|
* mobile where the package tree isn't resolvable from the packed worklet.
|
|
65
65
|
*/
|
|
66
66
|
backendsDir?: string;
|
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.ERR_CODES = exports.QvacErrorAddonOcrGgml = exports.OcrGgml = void 0;
|
|
|
5
5
|
const path = require("bare-path");
|
|
6
6
|
const fs = require("bare-fs");
|
|
7
7
|
const QvacLogger = require("@qvac/logging");
|
|
8
|
+
const fabricBackends = require("@qvac/fabric/backends");
|
|
8
9
|
/* eslint-enable @typescript-eslint/no-require-imports */
|
|
9
10
|
const infer_base_1 = require("@qvac/infer-base");
|
|
10
11
|
const ocr_ggml_1 = require("./ocr-ggml");
|
|
@@ -20,24 +21,20 @@ const DOCTR_INTERNAL_LANG_LIST = ["en"];
|
|
|
20
21
|
* create-time failures to ERR_CODES.UNSUPPORTED_LANGUAGE.
|
|
21
22
|
*/
|
|
22
23
|
const NATIVE_LANGUAGE_ERROR = /unsupported languages|only compatible with english/i;
|
|
23
|
-
// The ggml compute backends (GGML_BACKEND_DL modules) ship exactly once,
|
|
24
|
-
// @qvac/fabric
|
|
25
|
-
//
|
|
26
|
-
// consumer. On desktop,
|
|
27
|
-
//
|
|
28
|
-
// (the worklet runs from a packed bundle), so fall back to this addon's
|
|
29
|
-
// prebuilds, where the mobile packaging stages the backends. The native side
|
|
24
|
+
// The ggml compute backends (GGML_BACKEND_DL modules) ship exactly once, next to
|
|
25
|
+
// the @qvac/fabric runtime (<root>/<host>/qvac__fabric). We deliberately do not
|
|
26
|
+
// copy them into this addon to avoid duplicating tens of MB per fabric
|
|
27
|
+
// consumer. On desktop, @qvac/fabric/backends resolves that root in whichever
|
|
28
|
+
// package holds the runtime. On mobile the package tree isn't resolvable at
|
|
29
|
+
// runtime (the worklet runs from a packed bundle), so fall back to this addon's
|
|
30
|
+
// own prebuilds, where the mobile packaging stages the backends. The native side
|
|
30
31
|
// appends BACKENDS_SUBDIR ("<host>/qvac__fabric") to whichever root we return.
|
|
31
32
|
function resolveBackendsDir() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
// Mobile worklets cannot resolve the @qvac/fabric package tree.
|
|
40
|
-
}
|
|
33
|
+
// fabric's resolver only checks that the platform package resolves, not that
|
|
34
|
+
// its prebuilds are on disk.
|
|
35
|
+
const fabricRoot = fabricBackends.resolveBackendsDir();
|
|
36
|
+
if (fabricRoot !== null && fs.existsSync(fabricRoot))
|
|
37
|
+
return fabricRoot;
|
|
41
38
|
return path.join(__dirname, "prebuilds");
|
|
42
39
|
}
|
|
43
40
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qvac/ocr-ggml",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.1",
|
|
4
4
|
"description": "GGML-backed OCR addon for qvac (EasyOCR and DocTR pipelines on GGUF weights)",
|
|
5
5
|
"addon": true,
|
|
6
6
|
"engines": {
|
|
@@ -75,6 +75,8 @@
|
|
|
75
75
|
"bugs": "https://github.com/tetherto/qvac/issues",
|
|
76
76
|
"homepage": "https://qvac.tether.io",
|
|
77
77
|
"devDependencies": {
|
|
78
|
+
"@qvac/fabric-android-arm64": "^0.19.0",
|
|
79
|
+
"@qvac/fabric-ios": "^0.19.0",
|
|
78
80
|
"@qvac/registry-client": "^0.4.0",
|
|
79
81
|
"@types/node": "^24.2.1",
|
|
80
82
|
"bare-stream": "^2.7.0",
|
|
@@ -95,7 +97,7 @@
|
|
|
95
97
|
},
|
|
96
98
|
"dependencies": {
|
|
97
99
|
"@qvac/error": "^0.1.0",
|
|
98
|
-
"@qvac/fabric": "^0.
|
|
100
|
+
"@qvac/fabric": "^0.19.0",
|
|
99
101
|
"@qvac/infer-base": "^0.6.2",
|
|
100
102
|
"@qvac/logging": "^0.1.0",
|
|
101
103
|
"bare-fetch": "^3.0.1",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const { OcrGgml } = require('../..')
|
|
4
4
|
const test = require('brittle')
|
|
5
|
-
const path = require('bare-path')
|
|
6
5
|
const { MIN_MAIN_GPU_INDEX, MAX_MAIN_GPU_INDEX } = require('@qvac/ocr-ggml/lib/main-gpu')
|
|
7
6
|
const {
|
|
8
7
|
isMobile,
|
|
@@ -20,8 +19,9 @@ const {
|
|
|
20
19
|
// (covered by the rest of the suite), so this test only exercises the Vulkan
|
|
21
20
|
// opt-in path.
|
|
22
21
|
//
|
|
23
|
-
// The Vulkan execution path can only be validated where a `
|
|
24
|
-
// backend shared library
|
|
22
|
+
// The Vulkan execution path can only be validated where a `libqvac-ggml-vulkan`
|
|
23
|
+
// backend shared library ships, which on desktop is next to the @qvac/fabric
|
|
24
|
+
// runtime rather than in this package's prebuilds/. We gate on that file so
|
|
25
25
|
// the test skips cleanly on hosts that never built the Vulkan backend (e.g.
|
|
26
26
|
// plain desktop CI) instead of failing. On a host that ships the lib but has
|
|
27
27
|
// no Vulkan-capable GPU, the selection falls back to CPU and we assert the
|
|
@@ -29,7 +29,11 @@ const {
|
|
|
29
29
|
|
|
30
30
|
const TEST_TIMEOUT = 120 * 1000
|
|
31
31
|
|
|
32
|
-
const vulkanBackendLib = findVulkanBackendLib(
|
|
32
|
+
const vulkanBackendLib = findVulkanBackendLib(
|
|
33
|
+
isMobile
|
|
34
|
+
? PREBUILDS_DIR
|
|
35
|
+
: (require('@qvac/fabric/backends').resolveBackendsDir() ?? PREBUILDS_DIR)
|
|
36
|
+
)
|
|
33
37
|
|
|
34
38
|
// Skip on mobile (prebuilds layout / device provisioning differ) and on any
|
|
35
39
|
// host that did not ship a Vulkan backend lib.
|
|
@@ -37,7 +41,11 @@ const shouldSkip = isMobile || !vulkanBackendLib
|
|
|
37
41
|
|
|
38
42
|
function nativeBackendsDir() {
|
|
39
43
|
if (isMobile) return PREBUILDS_DIR
|
|
40
|
-
|
|
44
|
+
const dir = require('@qvac/fabric/backends').resolveBackendsDir()
|
|
45
|
+
if (dir === null) {
|
|
46
|
+
throw new Error('@qvac/fabric backends not found; is @qvac/fabric-<host> installed?')
|
|
47
|
+
}
|
|
48
|
+
return dir
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
for (const key of ['main-gpu', 'main_gpu']) {
|