I am developing a simple face detection in react native. i used tensorflow. and using mediapipe runtime. but its not creating or invoking the createDetector function.
i tried using both runtimes tfjs and mediapipe, tried with and without solutionPath, tried localPath instead of CDN in solutionPath.
but its just not calling that function. and below is what the catch block logged [TypeError: Cannot read property 'prototype' of undefined].
import '@tensorflow/tfjs-react-native';
import * as tf from '@tensorflow/tfjs';
import '@tensorflow/tfjs-backend-webgl';
import '@mediapipe/face_detection';
import * as faceDetection from '@tensorflow-models/face-detection';
useEffect(() => {
(async () => {
try {
const status = await Camera.requestCameraPermission();
console.log('status', status);
setHasPermission(status === 'granted');
console.log('initialized');
await tf.ready();
console.log('tf is ready');
const model = faceDetection.SupportedModels.MediaPipeFaceDetector;
const detectorConfig = {
runtime: 'mediapipe',
solutionPath: "/@mediapipe/face_detection",
};
console.log('model fetched', model);
console.log('FaceDetection Module:', faceDetection);
if (!faceDetection.createDetector) {
throw new Error('faceDetection.createDetector is undefined! Check imports.');
}
const faceDetector = await faceDetection.createDetector(model, detectorConfig);
console.log('detector initialized', faceDetector);
setDetector(faceDetector);
setLoading(false);
console.log('loading set to false');
} catch (error) {
console.log('error creating detector', error);
}
})();
}, []);```
``` (NOBRIDGE) LOG status granted
(NOBRIDGE) LOG initialized
(NOBRIDGE) LOG tf is ready
(NOBRIDGE) LOG model fetched MediaPipeFaceDetector
(NOBRIDGE) LOG FaceDetection Module: {"MediaPipeFaceDetectorMediaPipe": [Function MediaPipeFaceDetectorMediaPipe], "MediaPipeFaceDetectorTfjs": [Function MediaPipeFaceDetectorTfjs], "SupportedModels": {"MediaPipeFaceDetector": "MediaPipeFaceDetector"}, "createDetector": [Function createDetector]}
(NOBRIDGE) LOG error creating detector [TypeError: Cannot read property 'prototype' of undefined]```