MediaWiki:Gadget-LabelScan.js: Unterschied zwischen den Versionen
Admin (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Admin (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| Zeile 11: | Zeile 11: | ||
maxSide: 1024, | maxSide: 1024, | ||
debug: true, | debug: true, | ||
// nur fürs Debugging – Modell beim Klick immer „warmladen“ | |||
forceModelWarmup: true | forceModelWarmup: true | ||
}; | }; | ||
| Zeile 87: | Zeile 88: | ||
const mod = await import(/* webpackIgnore: true */ CFG.transformersURL); | const mod = await import(/* webpackIgnore: true */ CFG.transformersURL); | ||
// | // ⚙️ Runtime-Umgebung | ||
// | // NICHT localModelPath = null setzen! | ||
mod.env.remoteModels = true; | mod.env.remoteModels = true; | ||
mod.env.allowRemoteModels = true; | mod.env.allowRemoteModels = true; | ||
mod.env.useBrowserCache = true; | mod.env.useBrowserCache = true; | ||
// ( | // Versuch WebGPU zuzulassen (Chrome/Edge). Firefox ignoriert’s einfach. | ||
try { | |||
if ('gpu' in navigator) { | |||
mod.env.backends = mod.env.backends || {}; | |||
mod.env.backends.webgpu = { use: true }; | |||
log('Backend-Kandidat: WebGPU ist verfügbar.'); | |||
} | |||
} catch (_) { /* ignore */ } | |||
// ✅ WICHTIG: ONNXRuntime-WASM Pfad fest pinnen (Version kompatibel zu 2.15.0) | |||
mod.env.backends = mod.env.backends || {}; | mod.env.backends = mod.env.backends || {}; | ||
mod.env.backends.onnx = mod.env.backends.onnx || {}; | mod.env.backends.onnx = mod.env.backends.onnx || {}; | ||
mod.env.backends.onnx.wasm = mod.env.backends.onnx.wasm || {}; | mod.env.backends.onnx.wasm = mod.env.backends.onnx.wasm || {}; | ||
// | // Pin auf eine feste Version, damit .wasm-Dateien sicher gefunden werden: | ||
mod.env.backends.onnx.wasm.wasmPaths = 'https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/'; | mod.env.backends.onnx.wasm.wasmPaths = 'https://cdn.jsdelivr.net/npm/onnxruntime-web@1.20.0/dist/'; | ||
// Optional etwas konservativer: | |||
mod.env.backends.onnx.wasm.numThreads = 1; | |||
mod.env.backends.onnx.wasm.simd = true; | |||
// Pipeline laden | |||
const pipe = await mod.pipeline( | const pipe = await mod.pipeline( | ||
'feature-extraction', | 'feature-extraction', | ||
| Zeile 106: | Zeile 120: | ||
); | ); | ||
log('CLIP ready:', pipe.model?.constructor?.name || 'unknown'); | // Backend-Info loggen | ||
try { | |||
const backend = pipe?.engine?.backend || pipe?.model?.session?.executionProvider || 'unknown'; | |||
log('CLIP ready:', pipe.model?.constructor?.name || 'unknown', '| Backend:', backend); | |||
} catch (_) { | |||
log('CLIP ready:', pipe.model?.constructor?.name || 'unknown'); | |||
} | |||
return { mod, pipe }; | return { mod, pipe }; | ||
} catch(e){ | } catch(e){ | ||