UNPKG

react-native-executorch

Version:

An easy way to run AI models in React Native with ExecuTorch

19 lines (18 loc) 782 B
"use strict"; import { ResourceFetcher } from '../../utils/ResourceFetcher'; import { ETError, getError } from '../../Error'; import { BaseModule } from '../BaseModule'; export class ClassificationModule extends BaseModule { async load(model, onDownloadProgressCallback = () => {}) { const paths = await ResourceFetcher.fetch(onDownloadProgressCallback, model.modelSource); if (paths === null || paths.length < 1) { throw new Error('Download interrupted.'); } this.nativeModule = global.loadClassification(paths[0] || ''); } async forward(imageSource) { if (this.nativeModule == null) throw new Error(getError(ETError.ModuleNotLoaded)); return await this.nativeModule.generate(imageSource); } } //# sourceMappingURL=ClassificationModule.js.map