MCPcopy
hub / github.com/imgly/background-removal-js / initInference

Function initInference

packages/web/src/inference.ts:11–20  ·  view source on GitHub ↗
(config?: Config)

Source from the content-addressed store, hash-verified

9import { convertFloat32ToUint8 } from './utils';
10
11async function initInference(config?: Config) {
12 config = validateConfig(config);
13
14 if (config.debug) console.debug('Loading model...');
15 const model = config.model;
16 const blob = await loadAsBlob(`/models/${model}`, config);
17 const arrayBuffer = await blob.arrayBuffer();
18 const session = await createOnnxSession(arrayBuffer, config);
19 return { config, session };
20}
21
22async function runInference(
23 imageTensor: NdArray<Uint8Array>,

Callers

nothing calls this directly

Calls 3

validateConfigFunction · 0.90
loadAsBlobFunction · 0.90
createOnnxSessionFunction · 0.90

Tested by

no test coverage detected