react-native-executorch
Version:
An easy way to run AI models in React Native with ExecuTorch
18 lines (17 loc) • 648 B
JavaScript
import { OCRController } from '../../controllers/OCRController';
export class OCRModule {
static module;
static async load(model, onDownloadProgressCallback = () => { }) {
this.module = new OCRController({
modelDownloadProgressCallback: onDownloadProgressCallback,
});
await this.module.loadModel(model.detectorSource, {
recognizerLarge: model.recognizerLarge,
recognizerMedium: model.recognizerMedium,
recognizerSmall: model.recognizerSmall,
}, model.language);
}
static async forward(input) {
return await this.module.forward(input);
}
}