Skip to content

Commit a2d2d1f

Browse files
committed
fix: add native spec, make eslint happy
1 parent 08c50e1 commit a2d2d1f

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

src/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ export * from './ETModule';
22
export * from './RnExecutorch';
33
export * from './StyleTransfer';
44
export * from './constants/modelUrls';
5+
export * from './models/object_detection/ObjectDetection';
6+
export * from './models/object_detection/types';

src/models/object_detection/ObjectDetection.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ export const useObjectDetection = ({
2424

2525
useEffect(() => {
2626
const loadModel = async () => {
27+
let path = modelSource;
2728
if (typeof modelSource === 'number') {
28-
modelSource = Image.resolveAssetSource(modelSource).uri;
29+
path = Image.resolveAssetSource(modelSource).uri;
2930
}
3031

3132
try {
3233
setIsModelLoading(true);
33-
await ObjectDetection.loadModule(modelSource);
34+
await ObjectDetection.loadModule(path);
3435
} catch (e) {
3536
setError(getError(e));
3637
} finally {

src/models/object_detection/types.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
export interface Bbox {
1+
export interface Detection {
22
x1: number;
3-
y1: number;
43
x2: number;
4+
y1: number;
55
y2: number;
6-
}
7-
8-
export interface Detection {
9-
bbox: Bbox;
106
label: keyof typeof CocoLabel;
117
score: number;
128
}

src/native/NativeObjectDetection.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { TurboModule } from 'react-native';
2+
import { TurboModuleRegistry } from 'react-native';
3+
import { ObjectDetectionResult } from '../models/object_detection/types';
4+
5+
export interface Spec extends TurboModule {
6+
loadModule(modelSource: string): Promise<number>;
7+
forward(input: string): Promise<ObjectDetectionResult>;
8+
}
9+
10+
export default TurboModuleRegistry.get<Spec>('ObjectDetection');

0 commit comments

Comments
 (0)