@masumdev/rn-camera-ai-tflite 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -1
- package/lib/commonjs/detector/TFLiteCatAnalyzer.js +609 -0
- package/lib/commonjs/detector/TFLiteCatAnalyzer.js.map +1 -0
- package/lib/commonjs/detector/index.js +11 -0
- package/lib/commonjs/detector/index.js.map +1 -1
- package/lib/commonjs/detector/workletFrameHelper.js +233 -0
- package/lib/commonjs/detector/workletFrameHelper.js.map +1 -0
- package/lib/commonjs/parser/catParser.js +752 -0
- package/lib/commonjs/parser/catParser.js.map +1 -0
- package/lib/commonjs/parser/index.js +11 -0
- package/lib/commonjs/parser/index.js.map +1 -1
- package/lib/commonjs/types/cat.js +6 -0
- package/lib/commonjs/types/cat.js.map +1 -0
- package/lib/commonjs/types/index.js +11 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/detector/TFLiteCatAnalyzer.js +605 -0
- package/lib/module/detector/TFLiteCatAnalyzer.js.map +1 -0
- package/lib/module/detector/index.js +1 -0
- package/lib/module/detector/index.js.map +1 -1
- package/lib/module/detector/workletFrameHelper.js +226 -0
- package/lib/module/detector/workletFrameHelper.js.map +1 -0
- package/lib/module/parser/catParser.js +739 -0
- package/lib/module/parser/catParser.js.map +1 -0
- package/lib/module/parser/index.js +1 -0
- package/lib/module/parser/index.js.map +1 -1
- package/lib/module/types/cat.js +4 -0
- package/lib/module/types/cat.js.map +1 -0
- package/lib/module/types/index.js +1 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/commonjs/detector/TFLiteCatAnalyzer.d.ts +6 -0
- package/lib/typescript/commonjs/detector/TFLiteCatAnalyzer.d.ts.map +1 -0
- package/lib/typescript/commonjs/detector/index.d.ts +1 -0
- package/lib/typescript/commonjs/detector/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/detector/workletFrameHelper.d.ts +40 -0
- package/lib/typescript/commonjs/detector/workletFrameHelper.d.ts.map +1 -0
- package/lib/typescript/commonjs/parser/catParser.d.ts +61 -0
- package/lib/typescript/commonjs/parser/catParser.d.ts.map +1 -0
- package/lib/typescript/commonjs/parser/index.d.ts +1 -0
- package/lib/typescript/commonjs/parser/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/cat.d.ts +109 -0
- package/lib/typescript/commonjs/types/cat.d.ts.map +1 -0
- package/lib/typescript/commonjs/types/index.d.ts +1 -0
- package/lib/typescript/commonjs/types/index.d.ts.map +1 -1
- package/lib/typescript/module/detector/TFLiteCatAnalyzer.d.ts +6 -0
- package/lib/typescript/module/detector/TFLiteCatAnalyzer.d.ts.map +1 -0
- package/lib/typescript/module/detector/index.d.ts +1 -0
- package/lib/typescript/module/detector/index.d.ts.map +1 -1
- package/lib/typescript/module/detector/workletFrameHelper.d.ts +40 -0
- package/lib/typescript/module/detector/workletFrameHelper.d.ts.map +1 -0
- package/lib/typescript/module/parser/catParser.d.ts +61 -0
- package/lib/typescript/module/parser/catParser.d.ts.map +1 -0
- package/lib/typescript/module/parser/index.d.ts +1 -0
- package/lib/typescript/module/parser/index.d.ts.map +1 -1
- package/lib/typescript/module/types/cat.d.ts +109 -0
- package/lib/typescript/module/types/cat.d.ts.map +1 -0
- package/lib/typescript/module/types/index.d.ts +1 -0
- package/lib/typescript/module/types/index.d.ts.map +1 -1
- package/package.json +5 -10
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { CameraProcessor } from '@masumdev/rn-camera-ai';
|
|
2
|
+
import type { TFLiteModelSource, TensorflowModel } from './tflite.js';
|
|
3
|
+
/**
|
|
4
|
+
* Pipeline operating mode controlling which cat vision neural networks execute.
|
|
5
|
+
*/
|
|
6
|
+
export type CatAnalysisMode = 'all' | 'breed' | 'face_mood' | 'segmentation' | 'identity';
|
|
7
|
+
/**
|
|
8
|
+
* Active breed classification model engine selector.
|
|
9
|
+
*/
|
|
10
|
+
export type CatBreedEngine = '67' | '12' | 'ensemble';
|
|
11
|
+
/**
|
|
12
|
+
* Enrolled personal cat identity profile stored for cosine similarity matching.
|
|
13
|
+
*/
|
|
14
|
+
export interface EnrolledCatProfile {
|
|
15
|
+
/** Unique profile identifier */
|
|
16
|
+
id: string;
|
|
17
|
+
/** Custom cat nickname (e.g. 'Oyen', 'Mochi') */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Optional detected or user-provided breed hint */
|
|
20
|
+
breedHint?: string;
|
|
21
|
+
/** L2-normalized 96-D feline descriptor embedding */
|
|
22
|
+
embedding: number[];
|
|
23
|
+
/** Creation timestamp (epoch ms) */
|
|
24
|
+
createdAt: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Configuration options for creating a Multi-Model TFLite Cat Vision Analyzer.
|
|
28
|
+
*/
|
|
29
|
+
export interface TFLiteCatAnalyzerConfig {
|
|
30
|
+
/** Stage 1 COCO SSD object detector model (detect.tflite 300x300) */
|
|
31
|
+
detectorModel: TFLiteModelSource;
|
|
32
|
+
/** COCO labels array or index map */
|
|
33
|
+
detectorLabels?: string[] | Record<number, string>;
|
|
34
|
+
/** Index offset applied before COCO label lookup (default: 1) */
|
|
35
|
+
detectorLabelOffset?: number;
|
|
36
|
+
/** Detector input tensor width (default: 300) */
|
|
37
|
+
detectorInputWidth?: number;
|
|
38
|
+
/** Detector input tensor height (default: 300) */
|
|
39
|
+
detectorInputHeight?: number;
|
|
40
|
+
/** Extended 67-class Cat Breed & Coat Classifier model (224x224 float32 [0,1]) */
|
|
41
|
+
breed67Model?: TFLiteModelSource;
|
|
42
|
+
/** Label array for 67-class cat breed model */
|
|
43
|
+
breed67Labels?: readonly string[];
|
|
44
|
+
/** High-precision 12-class Oxford-IIIT Pet Cat Breed Classifier (224x224 uint8) */
|
|
45
|
+
breed12Model?: TFLiteModelSource;
|
|
46
|
+
/** Label array for 12-class breed model */
|
|
47
|
+
breed12Labels?: readonly string[];
|
|
48
|
+
/** Stage 2a Cat Face Localizer model (224x224 float32 [0,1] letterboxed) */
|
|
49
|
+
catFaceLocalizerModel?: TFLiteModelSource;
|
|
50
|
+
/** Stage 2b 48-point CatFLW Facial Landmarks model (384x384 float32 [0,1]) */
|
|
51
|
+
catFaceLandmarksModel?: TFLiteModelSource;
|
|
52
|
+
/** MediaPipe DeepLab-V3 21-class Semantic Segmenter (257x257 float32 [-1,1]) */
|
|
53
|
+
segmentationModel?: TFLiteModelSource;
|
|
54
|
+
/** Class index corresponding to 'cat' in segmentation outputs (default: 8) */
|
|
55
|
+
segmentationCatClassIndex?: number;
|
|
56
|
+
/** Initial active Cat AI pipeline mode (default: 'all') */
|
|
57
|
+
initialMode?: CatAnalysisMode;
|
|
58
|
+
/** Initial cat breed engine selection (default: 'ensemble') */
|
|
59
|
+
initialBreedEngine?: CatBreedEngine;
|
|
60
|
+
/** Minimum COCO SSD detection score threshold [0, 1] (default: 0.42) */
|
|
61
|
+
confidenceThreshold?: number;
|
|
62
|
+
/** Minimum cosine similarity threshold for Cat ID recognition [0, 1] (default: 0.72) */
|
|
63
|
+
similarityThreshold?: number;
|
|
64
|
+
/** Fall back to center close-up ROI when SSD misses an extreme close-up cat (default: true) */
|
|
65
|
+
closeUpFallback?: boolean;
|
|
66
|
+
/** Target FPS processing cap (default: 15) */
|
|
67
|
+
targetFps?: number;
|
|
68
|
+
/** Whether to prefer hardware GPU delegates before CPU fallback (default: true) */
|
|
69
|
+
useGpu?: boolean;
|
|
70
|
+
/** Optional initial list of enrolled cats */
|
|
71
|
+
initialCats?: EnrolledCatProfile[];
|
|
72
|
+
/** Delegate fallback callback */
|
|
73
|
+
onDelegateFallback?: (requested: string, fallback: string) => void;
|
|
74
|
+
/** Optional custom model loader function */
|
|
75
|
+
loadModel?: (source: TFLiteModelSource, delegates: string[]) => Promise<TensorflowModel>;
|
|
76
|
+
/** Platform override ('android' | 'ios') */
|
|
77
|
+
platform?: 'android' | 'ios' | string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Pluggable multi-model feline vision CameraProcessor contract.
|
|
81
|
+
*/
|
|
82
|
+
export interface TFLiteCatAnalyzer extends CameraProcessor {
|
|
83
|
+
readonly activeDelegate: 'gpu' | 'cpu';
|
|
84
|
+
readonly analysisMode: CatAnalysisMode;
|
|
85
|
+
readonly breedEngine: CatBreedEngine;
|
|
86
|
+
readonly confidenceThreshold: number;
|
|
87
|
+
readonly similarityThreshold: number;
|
|
88
|
+
readonly closeUpFallback: boolean;
|
|
89
|
+
readonly loadedModels: {
|
|
90
|
+
readonly detector: boolean;
|
|
91
|
+
readonly breed67: boolean;
|
|
92
|
+
readonly breed12: boolean;
|
|
93
|
+
readonly catFaceLocalizer: boolean;
|
|
94
|
+
readonly catFaceLandmarks: boolean;
|
|
95
|
+
readonly segmentation: boolean;
|
|
96
|
+
};
|
|
97
|
+
setAnalysisMode(mode: CatAnalysisMode): void;
|
|
98
|
+
setBreedEngine(engine: CatBreedEngine): void;
|
|
99
|
+
setConfidenceThreshold(threshold: number): void;
|
|
100
|
+
setSimilarityThreshold(threshold: number): void;
|
|
101
|
+
setCloseUpFallback(enabled: boolean): void;
|
|
102
|
+
enrollLastDetectedCat(name: string, breedHint?: string): EnrolledCatProfile | null;
|
|
103
|
+
enrollCat(name: string, embedding: Float32Array | number[], breedHint?: string): EnrolledCatProfile;
|
|
104
|
+
removeEnrolledCat(id: string): boolean;
|
|
105
|
+
clearEnrolledCats(): void;
|
|
106
|
+
getEnrolledCats(): EnrolledCatProfile[];
|
|
107
|
+
hasRecentCatEmbedding(): boolean;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=cat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cat.d.ts","sourceRoot":"","sources":["../../../../src/types/cat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EAChB,MAAM,aAAU,CAAC;AAElB;;GAEG;AACH,MA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,EAAE,OAAO,CAAC;QAC1B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;QACnC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;QACnC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;KAChC,CAAC;IACF,eAAe,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;IAC7C,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC7C,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAChD,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAChD,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3C,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAAC;IACnF,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,YAAY,GAAG,MAAM,EAAE,EAClC,SAAS,CAAC,EAAE,MAAM,GACjB,kBAAkB,CAAC;IACtB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACvC,iBAAiB,IAAI,IAAI,CAAC;IAC1B,eAAe,IAAI,kBAAkB,EAAE,CAAC;IACxC,qBAAqB,IAAI,OAAO,CAAC;CAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAU,CAAC;AACzB,cAAc,UAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masumdev/rn-camera-ai-tflite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "TensorFlow Lite object detection adapter for @masumdev/rn-camera-ai using react-native-fast-tflite.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -50,12 +50,10 @@
|
|
|
50
50
|
"bugs": {
|
|
51
51
|
"url": "https://github.com/masumrpg/nodejs-lib/issues"
|
|
52
52
|
},
|
|
53
|
-
"dependencies": {
|
|
54
|
-
"@masumdev/rn-camera-ai": "workspace:*"
|
|
55
|
-
},
|
|
56
53
|
"devDependencies": {
|
|
57
54
|
"@babel/core": "^7.25.0",
|
|
58
55
|
"@babel/preset-env": "^7.25.0",
|
|
56
|
+
"@masumdev/rn-camera-ai": "workspace:*",
|
|
59
57
|
"@react-native/babel-preset": "^0.86.0",
|
|
60
58
|
"@types/react": "~19.3.0",
|
|
61
59
|
"react-native-builder-bob": "^0.43.0",
|
|
@@ -67,19 +65,16 @@
|
|
|
67
65
|
"typescript": "^5.0.0"
|
|
68
66
|
},
|
|
69
67
|
"peerDependencies": {
|
|
70
|
-
"@masumdev/rn-camera-ai": "
|
|
68
|
+
"@masumdev/rn-camera-ai": ">=0.5.0",
|
|
71
69
|
"react": ">=18",
|
|
72
70
|
"react-native": "*",
|
|
73
71
|
"react-native-fast-tflite": ">=3.0.0",
|
|
74
72
|
"react-native-nitro-image": "*",
|
|
75
|
-
"react-native-nitro-modules": "
|
|
73
|
+
"react-native-nitro-modules": ">=0.37.0",
|
|
76
74
|
"react-native-vision-camera": ">=5.0.0",
|
|
77
|
-
"react-native-worklets": "
|
|
75
|
+
"react-native-worklets": "*"
|
|
78
76
|
},
|
|
79
77
|
"peerDependenciesMeta": {
|
|
80
|
-
"react-native-fast-tflite": {
|
|
81
|
-
"optional": true
|
|
82
|
-
},
|
|
83
78
|
"react-native-nitro-image": {
|
|
84
79
|
"optional": true
|
|
85
80
|
},
|