UNPKG

web-ai-toolkit

Version:

AI powered features on the web made easy

24 lines (23 loc) 633 B
import { _ as i, a as o, w as c } from "./utils-BzV5l7tu.js"; let s; async function f(e, a = "Xenova/resnet-50") { return new Promise(async (t, r) => { try { s || await w(a), typeof e != "string" && (e = URL.createObjectURL(e)); const n = await s(e); t(n); } catch (n) { r(n); } }); } async function w(e) { return new Promise(async (a) => { s || (i.allowLocalModels = !1, i.useBrowserCache = !1, s = await o("image-classification", e || "Xenova/resnet-50", { device: navigator.ml ? "webnn-npu" : await c() ? "webgpu" : "wasm" })), a(); }); } export { f as runClassifier };