web-ai-toolkit
Version:
AI powered features on the web made easy
25 lines (24 loc) • 680 B
JavaScript
import { _ as o, a as c } from "./transformers-kV3s9sef.js";
import { w as i } from "./utils-DJ16RMae.js";
let t;
async function _(e, a = "Xenova/trocr-small-printed") {
return new Promise(async (n, s) => {
try {
t || await w(a), typeof e != "string" && (e = URL.createObjectURL(e));
const r = await t(e);
n(r);
} catch (r) {
s(r);
}
});
}
async function w(e) {
return new Promise(async (a) => {
t || (o.allowLocalModels = !1, o.useBrowserCache = !1, t = await c("image-to-text", e || "Xenova/trocr-small-printed", {
device: navigator.ml ? "webnn" : await i() ? "webgpu" : "wasm"
})), a();
});
}
export {
_ as runOCR
};