@qvac/ocr-ggml 0.27.3 → 0.28.0
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 +2 -2
- package/binding.js +1 -1
- package/fit.js +1 -5
- package/index.d.ts +2 -3
- package/index.js +3 -5
- package/package.json +24 -5
- 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/prebuilds/win32-x64/qvac__ocr-ggml.bare.exports +0 -0
- package/test/integration/backend-device.test.js +1 -13
- package/lib/backends-dir.d.ts +0 -1
- package/lib/backends-dir.js +0 -16
package/README.md
CHANGED
|
@@ -175,7 +175,7 @@ bare examples/backend-device.js --backend metal
|
|
|
175
175
|
| `params.lowConfidenceThreshold` | `number` | | `0.4` | retry threshold (`easyocr` only) |
|
|
176
176
|
| `params.recognizerBatchSize` | `number` | | `32` | recognizer batch size (`easyocr` only) |
|
|
177
177
|
| `params.nThreads` | `number` | | `0` (auto) | CPU thread count for GGML; `<0` leaves the GGML default |
|
|
178
|
-
| `params.backendsDir` | `string` | | fabric backends
|
|
178
|
+
| `params.backendsDir` | `string` | | fabric's backends | directory holding `libqvac-ggml-*.so` backend shared libs. When omitted, the backends `@qvac/fabric` ships are loaded; fabric locates them next to its runtime on every platform |
|
|
179
179
|
| `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) |
|
|
180
180
|
| `params.main-gpu` / `params.main_gpu` | `number` \| `string` | | _prefer dedicated_ | Raw ggml registry index or strict GPU class; requires GPU `backendDevice`. See below. |
|
|
181
181
|
| `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) |
|
|
@@ -260,7 +260,7 @@ Behaviour and expectations:
|
|
|
260
260
|
`backendIsGpu` stat). It never silently does the wrong thing.
|
|
261
261
|
- **Required backend libs.** Vulkan execution needs the `libggml-vulkan`
|
|
262
262
|
backend shared library (`libggml-vulkan.so` / `.dll` / `.dylib`) present in
|
|
263
|
-
`backendsDir` (
|
|
263
|
+
`backendsDir` (by default, the directory `@qvac/fabric` ships its backends in), plus a working
|
|
264
264
|
Vulkan driver/ICD and a Vulkan-capable GPU on the host. **OpenCL** likewise
|
|
265
265
|
needs the `libggml-opencl` backend shared library plus a working OpenCL
|
|
266
266
|
runtime (`libOpenCL.so`); it is built primarily for **Android** (the `opencl`
|
package/binding.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// Pre-load @qvac/fabric so its shared .bare module (the ggml runtime) is
|
|
4
4
|
// registered with the bare runtime before our addon resolves its DT_NEEDED
|
|
5
|
-
// dependency qvac__fabric
|
|
5
|
+
// dependency qvac__fabric-<host>@0.bare (shipped by @qvac/fabric-<host>).
|
|
6
6
|
require('@qvac/fabric')
|
|
7
7
|
|
|
8
8
|
module.exports = require.addon()
|
package/fit.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, '__esModule', { value: true })
|
|
|
3
3
|
exports.assessFit = assessFit
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-require-imports -- bare-path exposes a CommonJS export shape. */
|
|
5
5
|
const path = require('bare-path')
|
|
6
|
-
const backends_dir_1 = require('./lib/backends-dir')
|
|
7
6
|
/**
|
|
8
7
|
* Assess loading the detector and recognizer weights from GGUF metadata.
|
|
9
8
|
* This does not load weights or account for image-dependent inference memory.
|
|
@@ -24,8 +23,5 @@ function assessFit(request) {
|
|
|
24
23
|
// Resolve lazily so importing this package never loads the native binding.
|
|
25
24
|
// eslint-disable-next-line @typescript-eslint/no-require-imports -- native prebuild is resolved lazily.
|
|
26
25
|
const binding = require('./binding')
|
|
27
|
-
return binding.assessFit(
|
|
28
|
-
...request,
|
|
29
|
-
backendsDir: request.backendsDir ?? (0, backends_dir_1.resolveBackendsDir)()
|
|
30
|
-
})
|
|
26
|
+
return binding.assessFit(request)
|
|
31
27
|
}
|
package/index.d.ts
CHANGED
|
@@ -61,9 +61,8 @@ export interface OcrGgmlParams {
|
|
|
61
61
|
*/
|
|
62
62
|
nThreads?: number;
|
|
63
63
|
/**
|
|
64
|
-
* Directory holding ggml backend shared libraries. Default: the
|
|
65
|
-
*
|
|
66
|
-
* mobile where the package tree isn't resolvable from the packed worklet.
|
|
64
|
+
* Directory holding ggml backend shared libraries. Default: the ones
|
|
65
|
+
* @qvac/fabric ships, which it locates itself next to its runtime.
|
|
67
66
|
*/
|
|
68
67
|
backendsDir?: string;
|
|
69
68
|
/**
|
package/index.js
CHANGED
|
@@ -11,7 +11,6 @@ const error_1 = require("./lib/error");
|
|
|
11
11
|
Object.defineProperty(exports, "QvacErrorAddonOcrGgml", { enumerable: true, get: function () { return error_1.QvacErrorAddonOcrGgml; } });
|
|
12
12
|
Object.defineProperty(exports, "ERR_CODES", { enumerable: true, get: function () { return error_1.ERR_CODES; } });
|
|
13
13
|
const main_gpu_1 = require("./lib/main-gpu");
|
|
14
|
-
const backends_dir_1 = require("./lib/backends-dir");
|
|
15
14
|
const fit_1 = require("./fit");
|
|
16
15
|
var fit_2 = require("./fit");
|
|
17
16
|
Object.defineProperty(exports, "assessFit", { enumerable: true, get: function () { return fit_2.assessFit; } });
|
|
@@ -163,10 +162,9 @@ class OcrGgml {
|
|
|
163
162
|
configurationParams[field] = this.params[field];
|
|
164
163
|
}
|
|
165
164
|
}
|
|
166
|
-
|
|
167
|
-
this.params.backendsDir
|
|
168
|
-
|
|
169
|
-
: (0, backends_dir_1.resolveBackendsDir)();
|
|
165
|
+
if (this.params.backendsDir !== undefined) {
|
|
166
|
+
configurationParams.backendsDir = this.params.backendsDir;
|
|
167
|
+
}
|
|
170
168
|
this.logger.info("Creating ocr-ggml addon");
|
|
171
169
|
try {
|
|
172
170
|
this.addon = this._createAddon(configurationParams);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qvac/ocr-ggml",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "GGML-backed OCR addon for qvac (EasyOCR and DocTR pipelines on GGUF weights)",
|
|
5
5
|
"addon": true,
|
|
6
6
|
"engines": {
|
|
@@ -77,13 +77,13 @@
|
|
|
77
77
|
"bugs": "https://github.com/tetherto/qvac/issues",
|
|
78
78
|
"homepage": "https://qvac.tether.io",
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@qvac/fabric-android-arm64": "
|
|
81
|
-
"@qvac/fabric-ios": "
|
|
80
|
+
"@qvac/fabric-android-arm64": "0.21.1",
|
|
81
|
+
"@qvac/fabric-ios": "0.21.1",
|
|
82
82
|
"@qvac/registry-client": "^0.4.0",
|
|
83
83
|
"@types/node": "^24.2.1",
|
|
84
84
|
"bare-stream": "^2.7.0",
|
|
85
85
|
"bare-subprocess": "^6.2.1",
|
|
86
|
-
"cmake-bare": "^1.
|
|
86
|
+
"cmake-bare": "^1.9.0",
|
|
87
87
|
"cmake-vcpkg": "^1.1.0",
|
|
88
88
|
"eslint": "^9.39.4",
|
|
89
89
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"@qvac/error": "^0.1.0",
|
|
102
|
-
"@qvac/fabric": "^0.
|
|
102
|
+
"@qvac/fabric": "^0.21.1",
|
|
103
103
|
"@qvac/infer-base": "^0.6.2",
|
|
104
104
|
"@qvac/logging": "^0.1.0",
|
|
105
105
|
"bare-fetch": "^3.0.1",
|
|
@@ -110,6 +110,25 @@
|
|
|
110
110
|
"bare-url": "^2.1.6",
|
|
111
111
|
"brittle": "^3.4.0"
|
|
112
112
|
},
|
|
113
|
+
"optionalDependencies": {
|
|
114
|
+
"@qvac/fabric-linux-x64": "^0.21.1",
|
|
115
|
+
"@qvac/fabric-linux-arm64": "^0.21.1",
|
|
116
|
+
"@qvac/fabric-darwin-arm64": "^0.21.1",
|
|
117
|
+
"@qvac/fabric-darwin-x64": "^0.21.1",
|
|
118
|
+
"@qvac/fabric-win32-x64": "^0.21.1"
|
|
119
|
+
},
|
|
120
|
+
"peerDependencies": {
|
|
121
|
+
"@qvac/fabric-android-arm64": "^0.21.1",
|
|
122
|
+
"@qvac/fabric-ios": "^0.21.1"
|
|
123
|
+
},
|
|
124
|
+
"peerDependenciesMeta": {
|
|
125
|
+
"@qvac/fabric-android-arm64": {
|
|
126
|
+
"optional": true
|
|
127
|
+
},
|
|
128
|
+
"@qvac/fabric-ios": {
|
|
129
|
+
"optional": true
|
|
130
|
+
}
|
|
131
|
+
},
|
|
113
132
|
"exports": {
|
|
114
133
|
"./package": "./package.json",
|
|
115
134
|
".": {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -31,24 +31,13 @@ const {
|
|
|
31
31
|
const TEST_TIMEOUT = 120 * 1000
|
|
32
32
|
|
|
33
33
|
const vulkanBackendLib = findVulkanBackendLib(
|
|
34
|
-
isMobile
|
|
35
|
-
? PREBUILDS_DIR
|
|
36
|
-
: (require('@qvac/fabric/backends').resolveBackendsDir() ?? PREBUILDS_DIR)
|
|
34
|
+
isMobile ? PREBUILDS_DIR : require('@qvac/fabric').backendsDir()
|
|
37
35
|
)
|
|
38
36
|
|
|
39
37
|
// Skip on mobile (prebuilds layout / device provisioning differ) and on any
|
|
40
38
|
// host that did not ship a Vulkan backend lib.
|
|
41
39
|
const shouldSkip = isMobile || !vulkanBackendLib
|
|
42
40
|
|
|
43
|
-
function nativeBackendsDir() {
|
|
44
|
-
if (isMobile) return PREBUILDS_DIR
|
|
45
|
-
const dir = require('@qvac/fabric/backends').resolveBackendsDir()
|
|
46
|
-
if (dir === null) {
|
|
47
|
-
throw new Error('@qvac/fabric backends not found; is @qvac/fabric-<host> installed?')
|
|
48
|
-
}
|
|
49
|
-
return dir
|
|
50
|
-
}
|
|
51
|
-
|
|
52
41
|
for (const key of ['main-gpu', 'main_gpu']) {
|
|
53
42
|
for (const value of [0, '+0', 'DEDICATED', 'Integrated']) {
|
|
54
43
|
test(
|
|
@@ -66,7 +55,6 @@ for (const key of ['main-gpu', 'main_gpu']) {
|
|
|
66
55
|
pathRecognizer,
|
|
67
56
|
langList: ['en'],
|
|
68
57
|
backendDevice,
|
|
69
|
-
backendsDir: nativeBackendsDir(),
|
|
70
58
|
[key]: value
|
|
71
59
|
},
|
|
72
60
|
() => {}
|
package/lib/backends-dir.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function resolveBackendsDir(): string;
|
package/lib/backends-dir.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveBackendsDir = resolveBackendsDir;
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-require-imports -- Bare modules and fabric expose CommonJS export shapes. */
|
|
5
|
-
const path = require("bare-path");
|
|
6
|
-
const fs = require("bare-fs");
|
|
7
|
-
const fabricBackends = require("@qvac/fabric/backends");
|
|
8
|
-
/* eslint-enable @typescript-eslint/no-require-imports */
|
|
9
|
-
// The ggml backends ship beside @qvac/fabric on desktop. Mobile bundles stage
|
|
10
|
-
// them beside this addon because the package tree is not resolved at runtime.
|
|
11
|
-
function resolveBackendsDir() {
|
|
12
|
-
const fabricRoot = fabricBackends.resolveBackendsDir();
|
|
13
|
-
if (fabricRoot !== null && fs.existsSync(fabricRoot))
|
|
14
|
-
return fabricRoot;
|
|
15
|
-
return path.join(__dirname, "..", "prebuilds");
|
|
16
|
-
}
|