@qvac/sdk 0.22.0 → 0.24.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/NOTICE +194 -97
- package/README.md +29 -470
- package/dist/examples/asr/parakeet-sortformer.js +24 -14
- package/dist/examples/asr/parakeet-transcribepsy-filesystem.d.ts +2 -0
- package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +105 -0
- package/dist/examples/asr/parakeet-unified-coreml.js +14 -9
- package/dist/examples/asr/whispercpp-prompt.js +9 -5
- package/dist/examples/assess-model-fit.d.ts +7 -9
- package/dist/examples/assess-model-fit.js +22 -43
- package/dist/examples/calc-tokens.d.ts +2 -0
- package/dist/examples/calc-tokens.js +21 -0
- package/dist/examples/classification/classify-image.js +11 -5
- package/dist/examples/completion-stop-reason.d.ts +3 -3
- package/dist/examples/completion-stop-reason.js +4 -4
- package/dist/examples/diffusion-flux3-klein.d.ts +2 -0
- package/dist/examples/diffusion-flux3-klein.js +102 -0
- package/dist/examples/diffusion-img2vid-ltx.js +7 -14
- package/dist/examples/diffusion-moss-image.d.ts +2 -0
- package/dist/examples/diffusion-moss-image.js +126 -0
- package/dist/examples/diffusion-qwen-image-21.d.ts +2 -0
- package/dist/examples/diffusion-qwen-image-21.js +115 -0
- package/dist/examples/diffusion-txt2vid-ltx.js +7 -14
- package/dist/examples/embed-multimodal.d.ts +2 -0
- package/dist/examples/embed-multimodal.js +80 -0
- package/dist/examples/embed-p2p.js +2 -2
- package/dist/examples/finetune/llamacpp-finetune.js +9 -4
- package/dist/examples/image/megaloc.d.ts +2 -0
- package/dist/examples/image/megaloc.js +37 -0
- package/dist/examples/llamacpp-multimodal.js +21 -1
- package/dist/examples/mcp-websearch.js +1 -1
- package/dist/examples/plugins.js +1 -1
- package/dist/examples/rag/rag-hyperdb/pipeline.js +2 -2
- package/dist/examples/rag/rag-turbovec.js +2 -2
- package/dist/examples/rerank.d.ts +2 -0
- package/dist/examples/rerank.js +33 -0
- package/dist/examples/sessions.d.ts +17 -0
- package/dist/examples/sessions.js +63 -0
- package/dist/examples/tools/llamacpp-deferred-tools.js +12 -8
- package/dist/examples/tools/llamacpp-tools-auto-dialect.js +4 -3
- package/dist/examples/tools/llamacpp-tools-gemma4.js +3 -3
- package/dist/examples/tools/llamacpp-tools-qwen35.js +4 -3
- package/dist/scripts/check-resource-collectors-packaging.js +7 -6
- package/dist/scripts/contract/build-contract.d.ts +2 -1
- package/dist/scripts/contract/build-contract.js +13 -1
- package/dist/scripts/contract/constants-registry.d.ts +19 -0
- package/dist/scripts/contract/constants-registry.js +9 -2
- package/dist/scripts/contract/method-shapes.d.ts +5 -0
- package/dist/scripts/contract/method-shapes.js +5 -0
- package/dist/scripts/enforce-inference-versions.d.ts +1 -1
- package/dist/scripts/enforce-inference-versions.js +28 -18
- package/dist/scripts/generate-bare-kit-runtimes.js +101 -69
- package/dist/src/client/api/assess-model-fit.d.ts +17 -17
- package/dist/src/client/api/assess-model-fit.js +19 -32
- package/dist/src/client/api/audio-edit.d.ts +5 -3
- package/dist/src/client/api/audio-edit.js +7 -5
- package/dist/src/client/api/audio-gen-result.js +136 -47
- package/dist/src/client/api/audio-gen.d.ts +40 -3
- package/dist/src/client/api/audio-gen.js +42 -5
- package/dist/src/client/api/audio-understand.d.ts +2 -2
- package/dist/src/client/api/audio-understand.js +4 -4
- package/dist/src/client/api/batch-completion.js +4 -3
- package/dist/src/client/api/bci-transcribe.js +3 -3
- package/dist/src/client/api/calc-tokens.d.ts +33 -0
- package/dist/src/client/api/calc-tokens.js +44 -0
- package/dist/src/client/api/cancel.d.ts +2 -2
- package/dist/src/client/api/cancel.js +3 -3
- package/dist/src/client/api/classify.d.ts +12 -5
- package/dist/src/client/api/classify.js +18 -6
- package/dist/src/client/api/client-request-id.d.ts +0 -15
- package/dist/src/client/api/client-request-id.js +15 -12
- package/dist/src/client/api/completion-stream.d.ts +9 -1
- package/dist/src/client/api/completion-stream.js +14 -3
- package/dist/src/client/api/decide.d.ts +1 -1
- package/dist/src/client/api/decide.js +3 -3
- package/dist/src/client/api/delete-cache.d.ts +9 -2
- package/dist/src/client/api/delete-cache.js +14 -4
- package/dist/src/client/api/diffusion.d.ts +38 -5
- package/dist/src/client/api/diffusion.js +42 -7
- package/dist/src/client/api/download-asset.js +3 -3
- package/dist/src/client/api/embed.d.ts +82 -29
- package/dist/src/client/api/embed.js +66 -21
- package/dist/src/client/api/finetune.js +3 -3
- package/dist/src/client/api/get-loaded-model-info.js +1 -1
- package/dist/src/client/api/get-model-info.d.ts +2 -2
- package/dist/src/client/api/get-model-info.js +3 -3
- package/dist/src/client/api/get-system-resources.d.ts +2 -2
- package/dist/src/client/api/get-system-resources.js +3 -3
- package/dist/src/client/api/heartbeat.d.ts +3 -2
- package/dist/src/client/api/heartbeat.js +4 -3
- package/dist/src/client/api/index.d.ts +8 -6
- package/dist/src/client/api/index.js +6 -4
- package/dist/src/client/api/invoke-plugin.d.ts +8 -2
- package/dist/src/client/api/invoke-plugin.js +18 -3
- package/dist/src/client/api/load-model.js +9 -6
- package/dist/src/client/api/logging-stream.d.ts +11 -2
- package/dist/src/client/api/logging-stream.js +12 -3
- package/dist/src/client/api/ocr.d.ts +5 -3
- package/dist/src/client/api/ocr.js +45 -22
- package/dist/src/client/api/rag.d.ts +1 -1
- package/dist/src/client/api/rag.js +3 -3
- package/dist/src/client/api/registry.d.ts +19 -8
- package/dist/src/client/api/registry.js +43 -17
- package/dist/src/client/api/rerank.d.ts +22 -0
- package/dist/src/client/api/rerank.js +39 -0
- package/dist/src/client/api/resume.d.ts +2 -1
- package/dist/src/client/api/resume.js +3 -3
- package/dist/src/client/api/rpc-server.d.ts +4 -4
- package/dist/src/client/api/rpc-server.js +12 -12
- package/dist/src/client/api/state.d.ts +2 -2
- package/dist/src/client/api/state.js +3 -3
- package/dist/src/client/api/subscribe-logs.d.ts +2 -2
- package/dist/src/client/api/subscribe-logs.js +4 -3
- package/dist/src/client/api/suspend.d.ts +4 -2
- package/dist/src/client/api/suspend.js +5 -4
- package/dist/src/client/api/text-to-speech.d.ts +14 -5
- package/dist/src/client/api/text-to-speech.js +86 -32
- package/dist/src/client/api/transcribe.d.ts +7 -3
- package/dist/src/client/api/transcribe.js +9 -3
- package/dist/src/client/api/translate.js +2 -2
- package/dist/src/client/api/unload-model.d.ts +19 -7
- package/dist/src/client/api/unload-model.js +31 -13
- package/dist/src/client/api/upscale.d.ts +6 -3
- package/dist/src/client/api/upscale.js +10 -5
- package/dist/src/client/api/vector-index.d.ts +51 -17
- package/dist/src/client/api/vector-index.js +101 -49
- package/dist/src/client/api/video-request.d.ts +5 -5
- package/dist/src/client/api/video.d.ts +3 -2
- package/dist/src/client/api/video.js +6 -5
- package/dist/src/client/api/vla.d.ts +9 -5
- package/dist/src/client/api/vla.js +17 -8
- package/dist/src/client/api/world-result.js +2 -2
- package/dist/src/client/api/world.d.ts +6 -6
- package/dist/src/client/api/world.js +6 -6
- package/dist/src/client/init-hooks.d.ts +6 -4
- package/dist/src/client/init-hooks.js +12 -15
- package/dist/src/client/logging-stream-registry.d.ts +6 -3
- package/dist/src/client/logging-stream-registry.js +36 -14
- package/dist/src/client/plugins-factory.d.ts +1 -1
- package/dist/src/client/plugins-factory.js +1 -1
- package/dist/src/client/rpc/bundle-stamp.d.ts +29 -0
- package/dist/src/client/rpc/bundle-stamp.js +75 -0
- package/dist/src/client/rpc/expo-home-dir.d.ts +2 -0
- package/dist/src/client/rpc/expo-home-dir.js +4 -0
- package/dist/src/client/rpc/expo-rpc-client.js +192 -138
- package/dist/src/client/rpc/node-rpc-client.js +324 -426
- package/dist/src/client/rpc/pear-runtime.d.ts +12 -0
- package/dist/src/client/rpc/pear-runtime.js +12 -0
- package/dist/src/client/rpc/rpc-client.d.ts +6 -4
- package/dist/src/client/rpc/rpc-client.js +168 -31
- package/dist/src/client/rpc/rpc-error.js +24 -2
- package/dist/src/client/rpc/unbundled-harness.d.ts +16 -0
- package/dist/src/client/rpc/unbundled-harness.js +27 -0
- package/dist/src/client/rpc/worker-failure.d.ts +27 -0
- package/dist/src/client/rpc/worker-failure.js +61 -0
- package/dist/src/client/session-registry.d.ts +75 -0
- package/dist/src/client/session-registry.js +149 -0
- package/dist/src/client/session.d.ts +125 -0
- package/dist/src/client/session.js +148 -0
- package/dist/src/commands/bundle/addons.d.ts +14 -0
- package/dist/src/commands/bundle/addons.js +65 -0
- package/dist/src/commands/bundle/constants.js +2 -0
- package/dist/src/commands/bundle/entry-gen.d.ts +1 -5
- package/dist/src/commands/bundle/entry-gen.js +18 -51
- package/dist/src/commands/bundle/index.d.ts +60 -14
- package/dist/src/commands/bundle/index.js +350 -126
- package/dist/src/commands/bundle/link.d.ts +58 -0
- package/dist/src/commands/bundle/link.js +135 -0
- package/dist/src/commands/bundle/node-support.d.ts +13 -0
- package/dist/src/commands/bundle/node-support.js +23 -0
- package/dist/src/commands/bundle/plugins.js +1 -1
- package/dist/src/commands/bundle/read-bundle.d.ts +9 -0
- package/dist/src/commands/bundle/read-bundle.js +27 -0
- package/dist/src/commands/bundle/resolve-sdk-import.d.ts +6 -0
- package/dist/src/commands/bundle/resolve-sdk-import.js +24 -28
- package/dist/src/commands/bundle/scratch.d.ts +35 -0
- package/dist/src/commands/bundle/scratch.js +178 -0
- package/dist/src/commands/bundle/targets.d.ts +14 -0
- package/dist/src/commands/bundle/targets.js +37 -0
- package/dist/src/commands/host-prebuilds/index.d.ts +8 -7
- package/dist/src/commands/host-prebuilds/index.js +13 -11
- package/dist/src/commands/index.d.ts +13 -12
- package/dist/src/commands/index.js +7 -7
- package/dist/src/commands/verify/abi.d.ts +21 -15
- package/dist/src/commands/verify/abi.js +12 -80
- package/dist/src/commands/verify/bare-kit-runtime.d.ts +20 -22
- package/dist/src/commands/verify/bare-kit-runtime.js +102 -150
- package/dist/src/commands/verify/bare-kit-runtimes.d.ts +10 -9
- package/dist/src/commands/verify/bare-kit-runtimes.js +21 -21
- package/dist/src/commands/verify/bundle-source.d.ts +1 -1
- package/dist/src/commands/verify/bundle-source.js +27 -23
- package/dist/src/commands/verify/engines-advice.d.ts +6 -12
- package/dist/src/commands/verify/engines-advice.js +9 -56
- package/dist/src/commands/verify/index.d.ts +34 -33
- package/dist/src/commands/verify/index.js +96 -204
- package/dist/src/commands/verify/node-modules-source.d.ts +1 -1
- package/dist/src/commands/verify/node-modules-source.js +1 -1
- package/dist/src/commands/verify/prebuilds.d.ts +4 -6
- package/dist/src/commands/verify/prebuilds.js +3 -4
- package/dist/src/commands/verify/resource-collectors.d.ts +0 -6
- package/dist/src/commands/verify/resource-collectors.js +3 -52
- package/dist/src/commands/verify/sidecar-runtime.d.ts +6 -0
- package/dist/src/commands/verify/sidecar-runtime.js +51 -0
- package/dist/src/expo/plugins/get-project-root.d.ts +1 -1
- package/dist/src/expo/plugins/withAndroidArchitecture.d.ts +1 -1
- package/dist/src/expo/plugins/withAndroidNdkVersion.d.ts +1 -1
- package/dist/src/expo/plugins/withAndroidNdkVersion.js +16 -10
- package/dist/src/expo/plugins/withBareKit.d.ts +59 -0
- package/dist/src/expo/plugins/withBareKit.js +204 -0
- package/dist/src/expo/plugins/withDeviceInfo.d.ts +1 -1
- package/dist/src/expo/plugins/withDeviceInfo.js +19 -5
- package/dist/src/expo/plugins/withMobileBundle.d.ts +5 -12
- package/dist/src/expo/plugins/withMobileBundle.js +38 -59
- package/dist/src/expo/plugins/withOpenCL.d.ts +1 -1
- package/dist/src/expo/plugins/withQvacSDK.d.ts +2 -1
- package/dist/src/expo/plugins/withQvacSDK.js +3 -0
- package/dist/src/index.d.ts +6 -5
- package/dist/src/index.js +10 -14
- package/dist/src/logging/addon.d.ts +1 -1
- package/dist/src/logging/base-logger.js +1 -1
- package/dist/src/logging/utils.js +11 -3
- package/dist/src/plugin-ids.d.ts +3 -1
- package/dist/src/plugin-ids.js +4 -0
- package/dist/src/schemas/public.d.ts +1 -1
- package/dist/src/schemas/public.js +1 -1
- package/dist/src/schemas/sdk-errors-client.d.ts +5 -6
- package/dist/src/schemas/sdk-errors-client.js +30 -36
- package/dist/src/schemas/sdk-errors-server.d.ts +12 -1
- package/dist/src/schemas/sdk-errors-server.js +65 -2
- package/dist/src/server/rpc/rpc-utils.d.ts +26 -0
- package/dist/src/server/rpc/rpc-utils.js +41 -0
- package/dist/src/utils/aggregate-events.d.ts +1 -1
- package/dist/src/utils/aggregate-events.js +2 -2
- package/dist/src/utils/errors-client.d.ts +37 -29
- package/dist/src/utils/errors-client.js +50 -41
- package/dist/src/utils/errors-server.d.ts +65 -1
- package/dist/src/utils/errors-server.js +122 -1
- package/dist/src/utils/mcp-adapter.d.ts +1 -1
- package/dist/src/utils/mcp-adapter.js +1 -1
- package/dist/src/utils/tool-helpers.js +1 -1
- package/dist/src/utils/withTimeout.js +34 -17
- package/dist/src/worker/handle-request.js +26 -21
- package/dist/src/worker/handler-utils.d.ts +2 -6
- package/dist/src/worker/handler-utils.js +2 -20
- package/dist/src/worker/index.d.ts +2 -4
- package/dist/src/worker/index.js +24 -34
- package/dist/src/worker/plugins/ggml-image-embedding.d.ts +2 -0
- package/dist/src/worker/plugins/ggml-image-embedding.js +1 -0
- package/dist/src/worker/plugins/llamacpp-rerank.d.ts +2 -0
- package/dist/src/worker/plugins/llamacpp-rerank.js +1 -0
- package/dist/src/worker/shim.d.ts +4 -0
- package/dist/src/worker/shim.js +7 -0
- package/dist/src/worker/start.d.ts +9 -0
- package/dist/src/worker/start.js +16 -0
- package/dist/src/worker/unbundled-shim.d.ts +2 -0
- package/dist/src/worker/unbundled-shim.js +4 -0
- package/docs/system-resources-support-matrix.md +27 -19
- package/package.json +91 -74
- package/src/electron-forge/index.cjs +65 -91
- package/dist/examples/model-fit-ui/server.d.ts +0 -24
- package/dist/examples/model-fit-ui/server.js +0 -221
- package/dist/src/client/rpc/ensure-worker-ready.d.ts +0 -9
- package/dist/src/client/rpc/ensure-worker-ready.js +0 -17
- package/dist/src/client/rpc/init-timeout.d.ts +0 -26
- package/dist/src/client/rpc/init-timeout.js +0 -25
- package/dist/src/client/rpc/worker-startup-error.d.ts +0 -12
- package/dist/src/client/rpc/worker-startup-error.js +0 -13
- package/dist/src/commands/bundle/bare-pack.d.ts +0 -21
- package/dist/src/commands/bundle/bare-pack.js +0 -77
- package/dist/src/commands/bundle/manifest.d.ts +0 -25
- package/dist/src/commands/bundle/manifest.js +0 -192
- package/dist/src/expo/plugins/link-addons.d.ts +0 -18
- package/dist/src/expo/plugins/link-addons.js +0 -65
- package/dist/src/pear/pre.d.ts +0 -21
- package/dist/src/pear/pre.js +0 -448
- package/dist/src/server/env.d.ts +0 -22
- package/dist/src/server/env.js +0 -59
- package/dist/src/server/utils/qvac-paths.d.ts +0 -2
- package/dist/src/server/utils/qvac-paths.js +0 -5
- package/dist/src/server/utils/worker-lock.d.ts +0 -3
- package/dist/src/server/utils/worker-lock.js +0 -67
- package/dist/src/worker/create-server.d.ts +0 -8
- package/dist/src/worker/create-server.js +0 -51
- package/dist/src/worker/lifecycle.d.ts +0 -23
- package/dist/src/worker/lifecycle.js +0 -149
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TranscribePsy transcription from an audio file.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* npx tsx examples/asr/parakeet-transcribepsy-filesystem.ts <audio-file> [--eu [--language en|other|auto]] [--coreml] [--window-sec <seconds>]
|
|
6
|
+
*
|
|
7
|
+
* TranscribePsy-250M-EU-sub is a 254M Parakeet-TDT distilled for Dutch,
|
|
8
|
+
* English, French, German, Italian, Polish, Portuguese and Spanish; the engine
|
|
9
|
+
* detects the language, so there is nothing to set. The default constant
|
|
10
|
+
* (`PARAKEET_TRANSCRIBEPSY_250M_Q8_0`) runs on ggml everywhere. On
|
|
11
|
+
* macOS and iOS, `--coreml` loads the Core ML distribution instead
|
|
12
|
+
* (`PARAKEET_TRANSCRIBEPSY_250M_COREML_Q8_0`): the SDK downloads its
|
|
13
|
+
* encoder and decoder bundles with the GGUF, and both stages run on the Neural
|
|
14
|
+
* Engine. Anywhere else that constant is refused at load time.
|
|
15
|
+
*
|
|
16
|
+
* `--eu` loads the full 25-language TranscribePsy-250M-EU instead
|
|
17
|
+
* (`PARAKEET_TRANSCRIBEPSY_250M_EU_Q8_0`): one GGUF with its CAFE language
|
|
18
|
+
* adapters and gate embedded, ggml on every platform, no Core ML distribution.
|
|
19
|
+
* `--language` picks its route: `en` for the English trunk, `other` for the
|
|
20
|
+
* non-English adapters, or `auto` (the default) to let the gate decide from
|
|
21
|
+
* the first seconds of the recording.
|
|
22
|
+
*
|
|
23
|
+
* Long recordings are encoded in overlapping windows, so memory stays flat
|
|
24
|
+
* however long the file is. Without `--window-sec` the engine uses the 60 s
|
|
25
|
+
* windows with 25 % overlap the model recommends; an explicit window is sent
|
|
26
|
+
* as encoder frames (12.5 per second) with a quarter of it as context, which
|
|
27
|
+
* is how a phone with little memory can trade speed for a smaller footprint.
|
|
28
|
+
*/
|
|
29
|
+
import { loadModel, unloadModel, transcribe, PARAKEET_TRANSCRIBEPSY_250M_Q8_0, PARAKEET_TRANSCRIBEPSY_250M_COREML_Q8_0, PARAKEET_TRANSCRIBEPSY_250M_EU_Q8_0 } from '@qvac/sdk';
|
|
30
|
+
const ENCODER_FRAMES_PER_SECOND = 12.5;
|
|
31
|
+
const RECOMMENDED_OVERLAP = 0.25;
|
|
32
|
+
const EU_LANGUAGES = ['en', 'other', 'auto'];
|
|
33
|
+
const USAGE = 'Usage: npx tsx examples/asr/parakeet-transcribepsy-filesystem.ts <audio-file> ' +
|
|
34
|
+
'[--eu [--language en|other|auto]] [--coreml] [--window-sec <seconds>]';
|
|
35
|
+
const args = process.argv.slice(2);
|
|
36
|
+
const valueFlags = new Set(['--window-sec', '--language']);
|
|
37
|
+
const audioFilePath = args.find((arg, index) => !arg.startsWith('--') && !valueFlags.has(args[index - 1] ?? ''));
|
|
38
|
+
const useCoreml = args.includes('--coreml');
|
|
39
|
+
const useEu = args.includes('--eu');
|
|
40
|
+
const windowIndex = args.indexOf('--window-sec');
|
|
41
|
+
const windowSeconds = windowIndex === -1 ? undefined : Number(args[windowIndex + 1]);
|
|
42
|
+
const languageIndex = args.indexOf('--language');
|
|
43
|
+
const language = languageIndex === -1 ? undefined : args[languageIndex + 1];
|
|
44
|
+
function isEuLanguage(value) {
|
|
45
|
+
return EU_LANGUAGES.includes(value ?? '');
|
|
46
|
+
}
|
|
47
|
+
if (!audioFilePath ||
|
|
48
|
+
(windowSeconds !== undefined && !(windowSeconds > 0)) ||
|
|
49
|
+
(useEu && useCoreml) ||
|
|
50
|
+
// `--language` needs a value, and only the full EU model has a route to pick.
|
|
51
|
+
(languageIndex !== -1 && (!useEu || !isEuLanguage(language)))) {
|
|
52
|
+
console.error(USAGE);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
// An explicit window becomes the engine's frame counts; the overlap is shared
|
|
56
|
+
// half and half with each neighbouring window.
|
|
57
|
+
const longForm = windowSeconds === undefined
|
|
58
|
+
? {}
|
|
59
|
+
: {
|
|
60
|
+
longFormWindowFrames: Math.round(windowSeconds * ENCODER_FRAMES_PER_SECOND),
|
|
61
|
+
longFormContextFrames: Math.round((windowSeconds * ENCODER_FRAMES_PER_SECOND * RECOMMENDED_OVERLAP) / 2)
|
|
62
|
+
};
|
|
63
|
+
// The EU route only means something to the full model; EU-sub has no gate.
|
|
64
|
+
const route = useEu && language !== undefined ? { language } : {};
|
|
65
|
+
const modelSrc = useEu
|
|
66
|
+
? PARAKEET_TRANSCRIBEPSY_250M_EU_Q8_0
|
|
67
|
+
: useCoreml
|
|
68
|
+
? PARAKEET_TRANSCRIBEPSY_250M_COREML_Q8_0
|
|
69
|
+
: PARAKEET_TRANSCRIBEPSY_250M_Q8_0;
|
|
70
|
+
const variant = useEu
|
|
71
|
+
? `EU, 25 languages, route ${language ?? 'auto'}`
|
|
72
|
+
: useCoreml
|
|
73
|
+
? 'EU-sub, Core ML distribution'
|
|
74
|
+
: 'EU-sub, ggml';
|
|
75
|
+
try {
|
|
76
|
+
console.log(`▸ Loading TranscribePsy (${variant})...`);
|
|
77
|
+
const modelId = await loadModel({
|
|
78
|
+
modelSrc,
|
|
79
|
+
modelType: 'parakeet-transcription',
|
|
80
|
+
modelConfig: { ...longForm, ...route },
|
|
81
|
+
onProgress: (p) => {
|
|
82
|
+
const mb = (n) => (n / 1e6).toFixed(1);
|
|
83
|
+
const line = `▸ Downloading ${p.percentage.toFixed(0)}% (${mb(p.downloaded)}/${mb(p.total)} MB)`;
|
|
84
|
+
process.stderr.write(process.stderr.isTTY ? `\r${line}` : `${line}\n`);
|
|
85
|
+
if (p.percentage >= 100)
|
|
86
|
+
process.stderr.write('\n');
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
console.log(windowSeconds === undefined
|
|
90
|
+
? '▸ Transcribing with the windows the model recommends (60 s, 25 % overlap)...'
|
|
91
|
+
: `▸ Transcribing in ${windowSeconds} s windows...`);
|
|
92
|
+
const call = transcribe({ modelId, audioChunk: audioFilePath });
|
|
93
|
+
const text = await call;
|
|
94
|
+
const stats = await call.stats;
|
|
95
|
+
console.log(text);
|
|
96
|
+
if (stats) {
|
|
97
|
+
console.log(`▸ ${stats.audioDuration?.toFixed(1) ?? '?'} s of audio, real-time factor ${stats.realTimeFactor?.toFixed(3) ?? '?'}` +
|
|
98
|
+
(useCoreml ? `, encoder on Core ML: ${stats.encoderUsedCoreml === 1 ? 'yes' : 'no'}` : ''));
|
|
99
|
+
}
|
|
100
|
+
await unloadModel({ modelId });
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
console.error('✖', error);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
@@ -3,17 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* From packages/sdk:
|
|
5
5
|
* npx tsx examples/asr/parakeet-unified-coreml.ts \
|
|
6
|
-
* /path/to/parakeet-unified-en-0.6b.q4_0.gguf
|
|
6
|
+
* /path/to/parakeet-unified-en-0.6b.q4_0.gguf <16-kHz-wav-file>
|
|
7
7
|
*
|
|
8
8
|
* The GGUF must be a regenerated Unified artifact. The five compiled Core ML
|
|
9
9
|
* files are downloaded through the SDK registry and staged beside the GGUF.
|
|
10
|
-
* The default audio is examples/audio/sample-16khz.wav.
|
|
11
10
|
*/
|
|
12
11
|
import { downloadAsset, getModelInfo, loadModel, transcribe, unloadModel } from '@qvac/sdk';
|
|
13
|
-
import { link, mkdir, mkdtemp, open, rm, symlink } from 'node:fs/promises';
|
|
12
|
+
import { copyFile, link, mkdir, mkdtemp, open, rm, symlink } from 'node:fs/promises';
|
|
14
13
|
import { tmpdir } from 'node:os';
|
|
15
14
|
import { basename, join, resolve } from 'node:path';
|
|
16
|
-
import { fileURLToPath } from 'node:url';
|
|
17
15
|
const MODEL_STEM = 'parakeet-unified-en-0.6b';
|
|
18
16
|
const COREML_FILES = [
|
|
19
17
|
['PARAKEET_UNIFIED_COREMLDATA', 'analytics/coremldata.bin'],
|
|
@@ -22,9 +20,8 @@ const COREML_FILES = [
|
|
|
22
20
|
['PARAKEET_UNIFIED_MODEL', 'model.mil'],
|
|
23
21
|
['PARAKEET_UNIFIED_WEIGHT', 'weights/weight.bin']
|
|
24
22
|
];
|
|
25
|
-
const defaultAudioPath = fileURLToPath(new URL('../audio/sample-16khz.wav', import.meta.url));
|
|
26
23
|
const modelPath = process.argv[2];
|
|
27
|
-
const audioPath = process.argv[3]
|
|
24
|
+
const audioPath = process.argv[3];
|
|
28
25
|
async function checkModel(path) {
|
|
29
26
|
const name = basename(path);
|
|
30
27
|
if (!/^parakeet-unified-en-0\.6b\.(?:f16|q4_0|q8_0)\.gguf$/.test(name)) {
|
|
@@ -66,7 +63,15 @@ async function stageModel(path) {
|
|
|
66
63
|
throw new Error(`Core ML file is missing from the SDK cache: ${name}`);
|
|
67
64
|
const targetPath = join(bundleDir, relativePath);
|
|
68
65
|
await mkdir(join(targetPath, '..'), { recursive: true });
|
|
69
|
-
|
|
66
|
+
try {
|
|
67
|
+
await link(sourcePath, targetPath);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
// A hard link cannot cross filesystems, e.g. a QVAC_HOME_DIR on another drive.
|
|
71
|
+
if (error.code !== 'EXDEV')
|
|
72
|
+
throw error;
|
|
73
|
+
await copyFile(sourcePath, targetPath);
|
|
74
|
+
}
|
|
70
75
|
}
|
|
71
76
|
return { modelSrc, dir };
|
|
72
77
|
}
|
|
@@ -76,9 +81,9 @@ async function stageModel(path) {
|
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
async function main() {
|
|
79
|
-
if (!modelPath) {
|
|
84
|
+
if (!modelPath || !audioPath) {
|
|
80
85
|
throw new Error('Usage: npx tsx examples/asr/parakeet-unified-coreml.ts ' +
|
|
81
|
-
'<regenerated-unified-gguf>
|
|
86
|
+
'<regenerated-unified-gguf> <16-kHz-wav-file>');
|
|
82
87
|
}
|
|
83
88
|
let staged;
|
|
84
89
|
let modelId;
|
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
* Whisper transcription with prompt example.
|
|
3
3
|
*
|
|
4
4
|
* Usage:
|
|
5
|
-
* npx tsx examples/asr/whispercpp-prompt.ts
|
|
5
|
+
* npx tsx examples/asr/whispercpp-prompt.ts <wav-file>
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Set audioChunk to a custom WAV, or download the default audio into examples/audio/:
|
|
7
|
+
* Pass the path of a 16 kHz mono WAV file. A sample is available in the QVAC
|
|
8
|
+
* source repository, but not included in the published npm package:
|
|
10
9
|
* https://github.com/tetherto/qvac/blob/main/packages/sdk/examples/audio/sample-16khz.wav
|
|
11
10
|
*/
|
|
12
11
|
import { loadModel, unloadModel, transcribe, WHISPER_TINY } from '@qvac/sdk';
|
|
12
|
+
const audioFilePath = process.argv[2];
|
|
13
|
+
if (!audioFilePath) {
|
|
14
|
+
console.error('Usage: npx tsx examples/asr/whispercpp-prompt.ts <wav-file>');
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
13
17
|
try {
|
|
14
18
|
console.log('▸ Starting Whisper transcription with prompt example...');
|
|
15
19
|
// Load the Whisper model
|
|
@@ -64,7 +68,7 @@ try {
|
|
|
64
68
|
console.log('▸ Transcribing audio...');
|
|
65
69
|
const text = await transcribe({
|
|
66
70
|
modelId,
|
|
67
|
-
audioChunk:
|
|
71
|
+
audioChunk: audioFilePath,
|
|
68
72
|
prompt: 'This is a test recording with clear speech and proper punctuation.'
|
|
69
73
|
});
|
|
70
74
|
console.log('▸ Transcription result:');
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Which models
|
|
3
|
-
*
|
|
2
|
+
* Which models fit this machine, asked before downloading any weights. Each
|
|
3
|
+
* engine's fitter reads the registry's weightless description of a model, so
|
|
4
|
+
* nothing is fetched beyond tens of KB, loaded or reserved.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `unknown` is a real answer, not an error: the evidence does not support a
|
|
11
|
-
* call either way. Show it as "can't say", never as "no".
|
|
6
|
+
* Each model gets its own verdict and the memory it takes on each device, and
|
|
7
|
+
* the set gets one verdict for all of them loaded together, with what it takes
|
|
8
|
+
* from each memory pool. `unknown` is a valid answer: show it as "can't say",
|
|
9
|
+
* never as "no".
|
|
12
10
|
*/
|
|
13
11
|
export {};
|
|
14
12
|
//# sourceMappingURL=assess-model-fit.d.ts.map
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Which models
|
|
3
|
-
*
|
|
2
|
+
* Which models fit this machine, asked before downloading any weights. Each
|
|
3
|
+
* engine's fitter reads the registry's weightless description of a model, so
|
|
4
|
+
* nothing is fetched beyond tens of KB, loaded or reserved.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `unknown` is a real answer, not an error: the evidence does not support a
|
|
11
|
-
* call either way. Show it as "can't say", never as "no".
|
|
6
|
+
* Each model gets its own verdict and the memory it takes on each device, and
|
|
7
|
+
* the set gets one verdict for all of them loaded together, with what it takes
|
|
8
|
+
* from each memory pool. `unknown` is a valid answer: show it as "can't say",
|
|
9
|
+
* never as "no".
|
|
12
10
|
*/
|
|
13
11
|
import { assessModelFit, QWEN3_600M_INST_Q4, QWEN3_1_7B_INST_Q4, QWEN3_4B_INST_Q4_K_M, QWEN3_8B_INST_Q4_K_M, QWEN3_8_27B_MULTIMODAL_UD_Q8_K_XL } from '@qvac/sdk';
|
|
14
|
-
//
|
|
15
|
-
// context out of the config `loadModel` would be given.
|
|
12
|
+
// The fitter sizes the load as `loadModel` would run it, context included.
|
|
16
13
|
const CONTEXT_TOKENS = 8192;
|
|
17
14
|
// A ladder ending well past what a laptop has, so one screen shows every verdict.
|
|
18
15
|
const CANDIDATES = [
|
|
@@ -23,8 +20,8 @@ const CANDIDATES = [
|
|
|
23
20
|
QWEN3_8_27B_MULTIMODAL_UD_Q8_K_XL
|
|
24
21
|
];
|
|
25
22
|
const VERDICT_MARK = {
|
|
26
|
-
|
|
27
|
-
'
|
|
23
|
+
fits: '✔',
|
|
24
|
+
'does-not-fit': '✖',
|
|
28
25
|
unknown: '?'
|
|
29
26
|
};
|
|
30
27
|
function gib(bytes) {
|
|
@@ -36,40 +33,22 @@ try {
|
|
|
36
33
|
modelSrc: model,
|
|
37
34
|
modelType: 'llamacpp-completion',
|
|
38
35
|
modelConfig: { ctx_size: CONTEXT_TOKENS }
|
|
39
|
-
}))
|
|
40
|
-
// Declared for aggregation only, not a scheduling instruction: 'sequential'
|
|
41
|
-
// counts the largest operation peak, 'concurrent' counts one per model.
|
|
42
|
-
execution: 'sequential',
|
|
43
|
-
policy: 'interactive-v1'
|
|
36
|
+
}))
|
|
44
37
|
});
|
|
45
|
-
console.log(`▸
|
|
46
|
-
if (result.budget) {
|
|
47
|
-
console.log(` ${gib(result.budget.availableAfterReserveBytes)} budget` +
|
|
48
|
-
` (${gib(result.budget.totalBytes)} total,` +
|
|
49
|
-
` ${gib(result.budget.usedBytes)} in use,` +
|
|
50
|
-
` ${gib(result.budget.availableBytes)} free,` +
|
|
51
|
-
` ${gib(result.budget.reservedBytes)} held back)`);
|
|
52
|
-
}
|
|
53
|
-
// Says which device the verdicts assume, when the model would run on a GPU.
|
|
54
|
-
const placement = result.assumptions.find((line) => line.includes('assumed to execute on'));
|
|
55
|
-
if (placement)
|
|
56
|
-
console.log(`▸ ${placement}`);
|
|
57
|
-
console.log(`\n▸ At ${CONTEXT_TOKENS} tokens of context`);
|
|
38
|
+
console.log(`▸ At ${CONTEXT_TOKENS} tokens of context, each model alone`);
|
|
58
39
|
for (const [index, model] of result.models.entries()) {
|
|
59
|
-
const
|
|
60
|
-
const size = gib(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
console.log(` ${mark} ${model.name.padEnd(46)} ${size} on disk ${needs}`);
|
|
65
|
-
// Present on every `unknown`, and worth surfacing: it names what is missing.
|
|
66
|
-
if (model.verdict === 'unknown') {
|
|
67
|
-
for (const reason of model.reasons)
|
|
68
|
-
console.log(` ${reason}`);
|
|
40
|
+
const candidate = CANDIDATES[index];
|
|
41
|
+
const size = gib(candidate.expectedSize).padStart(9);
|
|
42
|
+
console.log(` ${VERDICT_MARK[model.status]} ${candidate.name.padEnd(46)} ${size} on disk`);
|
|
43
|
+
for (const device of model.devices) {
|
|
44
|
+
console.log(` ${device.name.padEnd(10)} ${gib(device.usedBytes).padStart(10)}`);
|
|
69
45
|
}
|
|
70
46
|
}
|
|
71
|
-
console.log(`\n▸ All five together
|
|
72
|
-
|
|
47
|
+
console.log(`\n▸ All five loaded together: ${result.verdict}`);
|
|
48
|
+
for (const pool of result.pools) {
|
|
49
|
+
const free = pool.freeBytes === undefined ? 'no free figure' : `of ${gib(pool.freeBytes)} free`;
|
|
50
|
+
console.log(` ${pool.id.padEnd(14)} ${gib(pool.usedBytes).padStart(10)} ${free}`);
|
|
51
|
+
}
|
|
73
52
|
process.exit(0);
|
|
74
53
|
}
|
|
75
54
|
catch (error) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { QWEN3_600M_INST_Q4, calcTokens, close, loadModel, unloadModel } from '@qvac/sdk';
|
|
2
|
+
let modelId;
|
|
3
|
+
try {
|
|
4
|
+
modelId = await loadModel({ modelSrc: QWEN3_600M_INST_Q4 });
|
|
5
|
+
const raw = await calcTokens({ modelId, text: 'Summarize this conversation.' });
|
|
6
|
+
const rendered = await calcTokens({
|
|
7
|
+
modelId,
|
|
8
|
+
history: [{ role: 'system', content: 'You are a helpful assistant.' }],
|
|
9
|
+
text: 'Summarize this conversation.'
|
|
10
|
+
});
|
|
11
|
+
console.log({ raw, rendered });
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
console.error('✖', error);
|
|
15
|
+
process.exitCode = 1;
|
|
16
|
+
}
|
|
17
|
+
finally {
|
|
18
|
+
if (modelId)
|
|
19
|
+
await unloadModel({ modelId });
|
|
20
|
+
await close();
|
|
21
|
+
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import { loadModel, classify, unloadModel } from '@qvac/sdk';
|
|
2
|
+
import { loadModel, classify, unloadModel, MOBILENETV3_3CLASS_V3_FP16 } from '@qvac/sdk';
|
|
3
3
|
/**
|
|
4
|
-
* Classify an image
|
|
4
|
+
* Classify an image with MobileNetV3-Small, which produces three classes:
|
|
5
|
+
* "food", "report", "other".
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* No modelSrc is needed — the model ships inside @qvac/classification-ggml.
|
|
7
|
+
* Usage: npx tsx examples/classification/classify-image.ts <image-path>
|
|
8
8
|
*/
|
|
9
9
|
async function main() {
|
|
10
|
+
const imagePath = process.argv[2];
|
|
11
|
+
if (!imagePath) {
|
|
12
|
+
console.error('Usage: npx tsx examples/classification/classify-image.ts <image-path>');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
10
15
|
const modelId = await loadModel({
|
|
16
|
+
modelSrc: MOBILENETV3_3CLASS_V3_FP16,
|
|
11
17
|
modelType: 'ggml-classification'
|
|
12
18
|
});
|
|
13
|
-
const image = fs.readFileSync(
|
|
19
|
+
const image = fs.readFileSync(imagePath);
|
|
14
20
|
const results = await classify({ modelId, image });
|
|
15
21
|
console.log('Classification results:');
|
|
16
22
|
for (const { label, confidence } of results) {
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* `completion()` sets `stopReason` on the aggregated `final` promise to
|
|
5
5
|
* indicate why the model stopped generating:
|
|
6
6
|
*
|
|
7
|
-
* - `
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* - `"eos"` — natural end-of-sequence. The model finished on its own.
|
|
8
|
+
* - `"stopSequence"` — a configured stop sequence ended generation.
|
|
9
|
+
* - `undefined` — the backend did not report a specific stop reason.
|
|
10
10
|
* - `"length"` — the `predict` token budget was exhausted. Output is
|
|
11
11
|
* truncated; the model did not reach a natural stopping
|
|
12
12
|
* point.
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* `completion()` sets `stopReason` on the aggregated `final` promise to
|
|
5
5
|
* indicate why the model stopped generating:
|
|
6
6
|
*
|
|
7
|
-
* - `
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* - `"eos"` — natural end-of-sequence. The model finished on its own.
|
|
8
|
+
* - `"stopSequence"` — a configured stop sequence ended generation.
|
|
9
|
+
* - `undefined` — the backend did not report a specific stop reason.
|
|
10
10
|
* - `"length"` — the `predict` token budget was exhausted. Output is
|
|
11
11
|
* truncated; the model did not reach a natural stopping
|
|
12
12
|
* point.
|
|
@@ -47,7 +47,7 @@ try {
|
|
|
47
47
|
process.stdout.write(event.text);
|
|
48
48
|
}
|
|
49
49
|
const final1 = await run1.final;
|
|
50
|
-
console.log(`\n▸ stopReason: ${final1.stopReason ?? '(
|
|
50
|
+
console.log(`\n▸ stopReason: ${final1.stopReason ?? '(not reported)'}`);
|
|
51
51
|
// --- Case 2: predict budget exhausted → stopReason = "length" ---
|
|
52
52
|
console.log('\n▸ Case 2: predict budget hit (predict: 10)');
|
|
53
53
|
const run2 = completion({
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { close, diffusion, loadModel, unloadModel } from '@qvac/sdk';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
// FLUX.3 Image Klein text-to-image, or reference editing when reference images are passed.
|
|
5
|
+
// FLUX.3 pairs its diffusion model with a Qwen3-VL 4B text encoder and the FLUX.2 VAE.
|
|
6
|
+
// Defaults download pinned Hugging Face weights; overrides accept paths or URLs.
|
|
7
|
+
// FLUX.3 model terms: https://huggingface.co/black-forest-labs/flux-3-image-klein/blob/09561231f44e41381c461caf53d5452005a60ac9/LICENSE.md
|
|
8
|
+
const HF = 'https://huggingface.co';
|
|
9
|
+
const prompt = process.argv[2] || "A lovely cat holding a sign that says 'FLUX3'";
|
|
10
|
+
const outputDir = process.argv[3] || '.';
|
|
11
|
+
const diffusionModelSrc = process.argv[4] ||
|
|
12
|
+
`${HF}/leejet/flux-3-image-klein-GGUF/resolve/1c2ad2f9b9247ccca6506a23bdb033fdb0873321/flux3-image-klein-Q8_0.gguf`;
|
|
13
|
+
const llmModelSrc = process.argv[5] ||
|
|
14
|
+
`${HF}/Qwen/Qwen3-VL-4B-Instruct-GGUF/resolve/1cd86afb9a95c410a6038ab3b40d8b578c892266/Qwen3VL-4B-Instruct-Q4_K_M.gguf`;
|
|
15
|
+
const vaeModelSrc = process.argv[6] ||
|
|
16
|
+
`${HF}/Comfy-Org/Flux-2-Klein-4B/resolve/5b3abca5c0dc1ecd4eaf3340868d09063fc1c965/split_files/vae/flux2-vae.safetensors`;
|
|
17
|
+
const referencePaths = process.argv.slice(7);
|
|
18
|
+
const usage = 'Usage: node --import tsx examples/diffusion-flux3-klein.ts [prompt] [outputDir] [model] [llm] [vae] [...references]';
|
|
19
|
+
if (process.argv.includes('--help')) {
|
|
20
|
+
console.log(usage);
|
|
21
|
+
console.log('▸ Defaults download pinned Hugging Face weights. Model overrides accept paths or URLs.');
|
|
22
|
+
console.log('▸ Pass up to 10 reference image paths to edit them instead of generating from text.');
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
if (referencePaths.length > 10) {
|
|
26
|
+
console.error('✖ FLUX.3 accepts at most 10 reference images');
|
|
27
|
+
console.error(usage);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
function modelSource(source) {
|
|
31
|
+
return /^https?:\/\//.test(source) ? source : path.resolve(source);
|
|
32
|
+
}
|
|
33
|
+
let modelId;
|
|
34
|
+
try {
|
|
35
|
+
const init_images = referencePaths.map((file) => new Uint8Array(fs.readFileSync(file)));
|
|
36
|
+
console.log('▸ Loading FLUX.3 Image Klein split-layout model...');
|
|
37
|
+
modelId = await loadModel({
|
|
38
|
+
modelSrc: modelSource(diffusionModelSrc),
|
|
39
|
+
modelType: 'sdcpp-generation',
|
|
40
|
+
modelConfig: {
|
|
41
|
+
llmModelSrc: modelSource(llmModelSrc),
|
|
42
|
+
vaeModelSrc: modelSource(vaeModelSrc),
|
|
43
|
+
flash_attn: true
|
|
44
|
+
},
|
|
45
|
+
onProgress: (progress) => {
|
|
46
|
+
const mb = (bytes) => (bytes / 1e6).toFixed(1);
|
|
47
|
+
const line = `▸ Downloading ${progress.percentage.toFixed(0)}% (${mb(progress.downloaded)}/${mb(progress.total)} MB)`;
|
|
48
|
+
process.stderr.write(process.stderr.isTTY ? `\r${line}` : `${line}\n`);
|
|
49
|
+
if (progress.percentage >= 100)
|
|
50
|
+
process.stderr.write('\n');
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
console.log(`▸ Model loaded: ${modelId}`);
|
|
54
|
+
console.log(`▸ Generating: "${prompt}"`);
|
|
55
|
+
// Recommended settings for the distilled model: 16 Euler steps at CFG 1.
|
|
56
|
+
const { progressStream, outputs, stats } = diffusion({
|
|
57
|
+
modelId,
|
|
58
|
+
prompt,
|
|
59
|
+
...(init_images.length > 0 && { init_images }),
|
|
60
|
+
width: 512,
|
|
61
|
+
height: 512,
|
|
62
|
+
steps: 16,
|
|
63
|
+
cfg_scale: 1,
|
|
64
|
+
sampling_method: 'euler',
|
|
65
|
+
seed: 42
|
|
66
|
+
});
|
|
67
|
+
for await (const { step, totalSteps } of progressStream) {
|
|
68
|
+
console.log(`▸ step ${step}/${totalSteps}`);
|
|
69
|
+
}
|
|
70
|
+
const buffers = await outputs;
|
|
71
|
+
if (buffers.length === 0)
|
|
72
|
+
throw new Error('FLUX.3 returned no image.');
|
|
73
|
+
for (let i = 0; i < buffers.length; i++) {
|
|
74
|
+
const outputPath = path.join(outputDir, `flux3_${i}.png`);
|
|
75
|
+
fs.writeFileSync(outputPath, buffers[i]);
|
|
76
|
+
console.log(`▸ Saved ${outputPath}`);
|
|
77
|
+
}
|
|
78
|
+
console.log('▸ Stats:', await stats);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
console.error('✖', error);
|
|
82
|
+
process.exitCode = 1;
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
try {
|
|
86
|
+
if (modelId)
|
|
87
|
+
await unloadModel({ modelId, clearStorage: false });
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
console.error('✖ Unload failed:', error);
|
|
91
|
+
process.exitCode = 1;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
await close();
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
console.error('✖ Cleanup failed:', error);
|
|
98
|
+
process.exitCode = 1;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (!process.exitCode)
|
|
102
|
+
console.log('▸ Done');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadModel, unloadModel, video } from '@qvac/sdk';
|
|
1
|
+
import { GEMMA_3_12B_Q4_K_XL, loadModel, LTX_2_3_22B_DISTILLED_EMBEDDINGS_CONNECTORS, LTX_2_3_22B_Q5_K_M, LTX_2_3_AUDIO_VAE, LTX_2_3_VIDEO_VAE, unloadModel, video } from '@qvac/sdk';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
// Image-to-video (+ synchronized audio) with LTX-2. Unlike Wan I2V, LTX-2
|
|
@@ -9,22 +9,15 @@ import path from 'path';
|
|
|
9
9
|
// This example needs powerful hardware: LTX-2.3 is a ~21B model, budget at
|
|
10
10
|
// least 20+ GB of video / unified memory.
|
|
11
11
|
//
|
|
12
|
-
//
|
|
13
|
-
// default to public HuggingFace URLs (the SDK downloads http(s) sources
|
|
14
|
-
// directly). Pass your own paths / URLs via argv to override.
|
|
15
|
-
const HF = 'https://huggingface.co';
|
|
12
|
+
// Pass your own paths / URLs via argv to override any of the five sources.
|
|
16
13
|
const initImagePath = process.argv[2];
|
|
17
14
|
const prompt = process.argv[3] || 'the subject slowly turns and smiles, soft natural lighting, cinematic';
|
|
18
15
|
const outputDir = process.argv[4] || '.';
|
|
19
|
-
const diffusionModelSrc = process.argv[5] ||
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const audioVaeModelSrc = process.argv[8] ||
|
|
25
|
-
`${HF}/unsloth/LTX-2.3-GGUF/resolve/main/vae/ltx-2.3-22b-distilled_audio_vae.safetensors`;
|
|
26
|
-
const embeddingsConnectorsModelSrc = process.argv[9] ||
|
|
27
|
-
`${HF}/unsloth/LTX-2.3-GGUF/resolve/main/text_encoders/ltx-2.3-22b-distilled_embeddings_connectors.safetensors`;
|
|
16
|
+
const diffusionModelSrc = process.argv[5] || LTX_2_3_22B_Q5_K_M;
|
|
17
|
+
const llmModelSrc = process.argv[6] || GEMMA_3_12B_Q4_K_XL;
|
|
18
|
+
const vaeModelSrc = process.argv[7] || LTX_2_3_VIDEO_VAE;
|
|
19
|
+
const audioVaeModelSrc = process.argv[8] || LTX_2_3_AUDIO_VAE;
|
|
20
|
+
const embeddingsConnectorsModelSrc = process.argv[9] || LTX_2_3_22B_DISTILLED_EMBEDDINGS_CONNECTORS;
|
|
28
21
|
if (!initImagePath) {
|
|
29
22
|
console.error('✖ init image path is required');
|
|
30
23
|
console.error('Usage: node dist/examples/diffusion-img2vid-ltx.js ' +
|