2021-05-11 17:34:40 +00:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
// Licensed under the MIT License.
|
|
|
|
|
|
2024-08-14 23:51:22 +00:00
|
|
|
import { NativeModules } from 'react-native';
|
2021-05-11 17:34:40 +00:00
|
|
|
|
|
|
|
|
export interface MNISTInput {
|
|
|
|
|
[name: string]: {
|
2024-08-14 23:51:22 +00:00
|
|
|
dims: number[];
|
|
|
|
|
type: string;
|
|
|
|
|
data: string; // encoded tensor data
|
2021-05-11 17:34:40 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface MNISTOutput {
|
|
|
|
|
[name: string]: {
|
2024-08-14 23:51:22 +00:00
|
|
|
data: string; // encoded tensor data
|
2021-05-11 17:34:40 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface MNISTResult {
|
|
|
|
|
result: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type MNISTType = {
|
2024-08-14 23:51:22 +00:00
|
|
|
getLocalModelPath(): Promise<string>;
|
|
|
|
|
getImagePath(): Promise<string>;
|
|
|
|
|
preprocess(uri: string): Promise<MNISTInput>;
|
2021-05-11 17:34:40 +00:00
|
|
|
postprocess(result: MNISTOutput): Promise<MNISTResult>;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const MNIST = NativeModules.MNISTDataHandler;
|
|
|
|
|
|
|
|
|
|
export default MNIST as MNISTType;
|