tfjs
tfjs copied to clipboard
[tfjs-react-native] Is there any way to speed up the performance of tfjs_graph_model
I had converted saved_model to tfjs_graph_model, the model.predict process cost 90 seconds with tfjs-react-native. Is there any way to speed up the performance?
OS Platform: M1 pro
Converted from this model
tensorflowjs_converter \
--input_format=tf_saved_model \
--output_format=tfjs_graph_model \
--signature_name=serving_default \
--saved_model_tags=serve \
/home/operator/light_paprika_SavedModel \
/home/operator/light_paprika_tfjs
code
const shinkaiModel = require("./models/light_paprika_tfjs/group1-shard1of1.bin");
const shinkaiModelJson = require("./models/light_paprika_tfjs/model.json");
const loadCartoonModel = async (inputImg) => {
await tf.ready();
let start = Date.now();
const cartoonModel = await tf.loadGraphModel(bundleResourceIO(shinkaiModelJson,shinkaiModel));
console.log("model loaded ",Date.now()-start); //554 ms
const imgTensor = await imgToTensor(inputImg);
console.log("img tensor ",Date.now()-start); //661 ms
const res = await cartoonModel.predict(imgTensor);
console.log("predict", Date.now()-start); //94951 ms
const img = await tensorToImg(res, inputImg.width, inputImg.height);
setImgCartoon({ uri: img });
}
Thanks
It seems that something strange happened. Try to use tensorflow-lite as a Native Module in your RN project.
Hi, @bergkamp
Apologize for the delayed response and we're re-visiting our older issues and checking whether those issues got resolved or not as of now so May I know are you still looking for the solution or your issue got resolved ?
If issue still persists please let us know ? May I know model size and on which backend are you executing the code like CPU, GPU, WASM or WebGL please ?
If possible please help us which version of react-native
and expo
are you using if possible please help us with package.json file
Could you please confirm if this issue is resolved for you ? Please feel free to close the issue if it is resolved ? Thank you!
This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.
This issue was closed due to lack of activity after being marked stale for past 7 days.