Closed Lonoyaa closed 1 year ago
I rebuild the project with expo and manage to use rn-webgl as backend then it sucesses to return keypoint array. If I switch to cpu backend then it doesn't work.
So, it's not possible to use cpu backend with react native (managed by react-native-cli)? Or is there any advices?
Hi, @Lonoyaa
Apologize for the delayed response and It seems like Face Landmarks Detection
pre-trained model will work on tfjs-backend-webgl
as runtime and I see in documentation it has mentioned, In the runtime-backend dropdown, choose 'tfjs-webgl'
here and in the peer dependencies of face-landmarks-detection it has used below script tag so I'm not sure at the moment whether is it possible to use cpu backend with react native
but we'll update you soon. Thank you!
CC :@linchenn
Via script tags:
<!-- Require the peer dependencies of face-landmarks-detection. -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-converter"></script>
<!-- You must explicitly require a TF.js backend if you're not using the TF.js union bundle. -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-webgl"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/face-detection"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/face-landmarks-detection"></script>
Via npm:
yarn add @tensorflow/tfjs-core, @tensorflow/tfjs-converter
yarn add @tensorflow/tfjs-backend-webgl
yarn add @tensorflow-models/face-detection
yarn add @tensorflow-models/face-landmarks-detection
Hi, @gaikwadrahul8 Thank you for your answer, it works after I change the backend to rn-webgl.
Hi, @Lonoyaa
Apologize for the delayed response and you're welcome, Good to hear that your issue got resolved so please feel free to close this issue if this issue got resolved for you. Thank you!
Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template
System information
Describe the current behavior FaceLandmarkDetection.estimateFace(inputTensor3D) return empty array Describe the expected behavior estimateFace return face array contain box and keypoints Standalone code to reproduce the issue
},"
const image = require('./assets/Face.jpeg'); const imageAssetPath = Image.resolveAssetSource(image); const response = await fetch(imageAssetPath.uri, {}, { isBinary: true }); const imageDataArrayBuffer = await response.arrayBuffer(); const imageData1 = new Uint8Array(imageDataArrayBuffer); const imageTensor1 = decodeJpeg(imageData1); const test = await modelReady?.estimateFaces(imageTensor1) console.log('test0',test)
Other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.
At the top, I call tf.setBackend('cpu') before tf.ready(), not sure if it's related