thank you so much for this video the way you teach is incredible , breaking all the parts into tiny bits through the PPT really helped in understanding things easily
Hi, your tutorial is useful. I get stuck with loading the .bin file. It showed some error saying cannot find the .bin file even I have correctly specified the path. But after following your tutorial and adding metro.config.js, it's working! I would like to know what metro.config.js does and why it works. Could you explain a bit more or give some ref/resource, please?
Thank you for the video. Actually, The context of deployment is the same in my project as well. I want to deploy in react native too. But I am working with structured datasets where the values of each feature should be fed to the model. How should I do that?
API Documentation states that bundleResourceIO does not work with Expo managed apps. But good example overall coz you loaded your custom model unlike everyone showing how to load pre-trained js models. keep up the great work, my friend
Hey, I downloaded the React Native project from your github page, but when I ran 'expo start' and loaded the project into an emulator, it couldn't connect to the model file so the 'predict' button didn't do anything. What version of NPM to use?
Thanks so much, this helped me a ton. I am able to load the model. However, when I try to do model.predict, it says I have a dynamic op 'Exit', so I should use executeAsync. executeAsync also doesn't work-the output of model.executeAsync is {"_A": null, "_x": 0, "_y": -, "_z": null}. I think this may be caused by the warning absl found untraced functions such as... when converting the model. Many users have reported that the warning corrupts the model. Do you know how I can deploy an LSTM model? Thank you so much.
I cant download tensorflow js due to this error: ERROR: Cannot install flax because these package versions have conflicting dependencies. The conflict is caused by: optax 0.1.2 depends on jaxlib>=0.1.37 optax 0.1.1 depends on jaxlib>=0.1.37 optax 0.1.0 depends on jaxlib>=0.1.37 optax 0.0.91 depends on jaxlib>=0.1.37 optax 0.0.9 depends on jaxlib>=0.1.37 optax 0.0.8 depends on jaxlib>=0.1.37 optax 0.0.6 depends on jaxlib>=0.1.37 optax 0.0.5 depends on jaxlib>=0.1.37 optax 0.0.3 depends on jaxlib>=0.1.37 optax 0.0.2 depends on jaxlib>=0.1.37 optax 0.0.1 depends on jaxlib>=0.1.37 do you have any ideas how to resolve it?
Hi bro , we cannot use tflite in react . Because JavaScript only supports JSON file not tflite. Tflite is made for native platforms such as android studio and swift , also now used in flutter.
Hello, when I run the program it gives me this error: "Size(8192) must match the product of shape 0,0,0]". What would be the best approach to solve this problem? Thanks
Hi there, thank you very much for the video. But I am experiencing an error constantly. I downloaded a saved model from tensorflow hub, it was a neural style transfer model. I also converted it to shards using the tfjs converter. I got 23 shards after that which I bundled up into a big shard.bin file. Then put it into the assets folder and loaded it the way you have shown in the video. However, when I try to run the app on my phone it gives me the error Failed building JavaScript bundle. assets\group1-shard.bin: Cannot read property 'length' of undefined I have tried searching a lot for this issue and couldn't find any resolutions. My project is also an expo managed project and I have configured my metro.config.js the exact way shown in the video. Please help me with this issue. I really need it. Thank you.
@@chirpieful I did that and your project works beautifully. I just don't understand why am I still getting an error when I am trying to do the same thing with a different model.
@@chirpieful Hey, Sooo... after a lot of trying and refactoring I have managed to load the style transfer model. Get images from the user and also convert them into tensors properly, but I don't know how I can pass two tensors to the model. Any idea on how I can do that. I have tried passing the tensors in an array, but it doesn't seem to work.
@@chirpieful Yes I did that, called the model.predict then passed it an array of two tensors, it didn't work caught an error in the try catch block. Unknown op 'MirrorPad'. File an issue at github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp() Any idea what this is?
@@chirpieful "TensorFlow.js Layers currently only supports Keras models using standard Keras constructs. Models using unsupported ops or layers-e.g. custom layers, Lambda layers, custom losses, or custom metrics-cannot be automatically imported, because they depend on Python code that cannot be reliably translated into JavaScript. " stated in www.tensorflow.org/js/tutorials/conversion/import_keras
@@chirpieful Possible Unhandled Promise Rejection (id: 6): Error: Unknown layer: KerasLayer. This may be due to one of the following reasons: 1. The layer is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code. 2. The custom layer is defined in JavaScript, but is not registered properly with tf.serialization.registerClass(). And this is the error shown in my case, is there any ways I can solve it?QAQ Thanks anway
@@chirpieful Extremely thanks to you! I got stuck for a month with looking the tutorial like this to learn!I have additional question...do you have the presentation file for the video you tutor about building project with python..step to work with python..? thank you!
Hi Oh Yicong Thanks for the tutorial. It taught me how to deploy a custom built model with react-native. However I am facing a few issues with your model. I downloaded the code from github and did an expo build. I tried to run on android emulator. Nothing happens when I press Predict button. I find the following error 2021-06-03 23:29:54.773 16614-16755/com.sankarai.aiapp I/ReactNativeJS: [-] Unable to load image2021-06-03 23:29:54.773 16614-16755/com.sankarai.aiapp I/ReactNativeJS: [-] Unable to load image The second problem I am having is in the classifier app I am developing. I used your code as the baseline. The model predict output is zero for all the classes when it should be some decimal value of probabilities. I verified that this is not due to model as I am experiencing same behaviour with your model as well for 2 classes. Further I commented out the face detection part in your code and fed the image directly to the model. The results for both classes is again zero (ie Result[0] and Result[1] you are comparing to decide if there is a face mask or not). I cant seem to figure out if there is something missing in my environment. Can you please help?
Mhmm.. if everything is zero, I suspect that the image is not loaded into the model at all. Do check your input, make sure that there are values in it.
@@chirpieful I am passing the tensor after resizing and reshaping o 4 dimensions. In fact it complained when I did not reshape saying that 4 dimensions are expected. So I certainly know that the input has been taken. I also tried to feed a tensor of ones and zeros. Still same result. Is there any way of verifying if the image is loaded?
Thanks a lot, you have helped me a lot. Incredible job, nobody else is sharing a project like this. 👍👍👍
Glad that it helped :)
thank you so much for this video
the way you teach is incredible , breaking all the parts into tiny bits through the PPT really helped in understanding things easily
Have you deployed the model in react native while taking assistance from this video
Good stuff!
thanks 4 this video
Hi, your tutorial is useful. I get stuck with loading the .bin file. It showed some error saying cannot find the .bin file even I have correctly specified the path. But after following your tutorial and adding metro.config.js, it's working! I would like to know what metro.config.js does and why it works. Could you explain a bit more or give some ref/resource, please?
Thank you for the video. Actually, The context of deployment is the same in my project as well. I want to deploy in react native too. But I am working with structured datasets where the values of each feature should be fed to the model. How should I do that?
API Documentation states that bundleResourceIO does not work with Expo managed apps. But good example overall coz you loaded your custom model unlike everyone showing how to load pre-trained js models. keep up the great work, my friend
Thanks for highlighting.
so then what's the alternative to using bundleResourceIO?
@@JasonOwlbright hi there, this still works! You need to use it in pure react native environment, without expo.
@@chirpieful any ideas on what to do if i am using Expo?
@@JasonOwlbright mhmm... to be honest, I used expo managed environment in this video. I didn't face any problem yet.
GOOD
Hi im in need of your help, im willing to do the same with MNSIT dataset, how can i ?
Hey, I downloaded the React Native project from your github page, but when I ran 'expo start' and loaded the project into an emulator, it couldn't connect to the model file so the 'predict' button didn't do anything. What version of NPM to use?
Thanks so much, this helped me a ton. I am able to load the model. However, when I try to do model.predict, it says I have a dynamic op 'Exit', so I should use executeAsync. executeAsync also doesn't work-the output of model.executeAsync is {"_A": null, "_x": 0, "_y": -, "_z": null}. I think this may be caused by the warning absl found untraced functions such as... when converting the model. Many users have reported that the warning corrupts the model. Do you know how I can deploy an LSTM model? Thank you so much.
I'm having trouble loading into an expo app, tfjs-react-native is having problem with peer-dependencies, can you please provide a solution
is it possible to deploy yolov5 model in the same manner?
i am facing error while it requires binary that no file exists but it exists in same assets folder as jsn file is
Can you provide code for video compression for React native??
Can you guide how to load the model from documents directory on iOS/android instead of assets folder ?
I cant download tensorflow js due to this error: ERROR: Cannot install flax because these package versions have conflicting dependencies.
The conflict is caused by:
optax 0.1.2 depends on jaxlib>=0.1.37
optax 0.1.1 depends on jaxlib>=0.1.37
optax 0.1.0 depends on jaxlib>=0.1.37
optax 0.0.91 depends on jaxlib>=0.1.37
optax 0.0.9 depends on jaxlib>=0.1.37
optax 0.0.8 depends on jaxlib>=0.1.37
optax 0.0.6 depends on jaxlib>=0.1.37
optax 0.0.5 depends on jaxlib>=0.1.37
optax 0.0.3 depends on jaxlib>=0.1.37
optax 0.0.2 depends on jaxlib>=0.1.37
optax 0.0.1 depends on jaxlib>=0.1.37
do you have any ideas how to resolve it?
Hi, i tried this method but i always get this error Error: Unknown layer: KerasLayer .
how can i solve it?
thank you for this tutorial. Could you inform "How TensorFlow Lite model is deployed to react native?"
Hi bro , we cannot use tflite in react . Because JavaScript only supports JSON file not tflite. Tflite is made for native platforms such as android studio and swift , also now used in flutter.
not working in expo app
Hello, when I run the program it gives me this error: "Size(8192) must match the product of shape 0,0,0]". What would be the best approach to solve this problem? Thanks
Is it an invalid image?
@@chirpieful The image is valid.
Hi there, thank you very much for the video. But I am experiencing an error constantly. I downloaded a saved model from tensorflow hub, it was a neural style transfer model. I also converted it to shards using the tfjs converter. I got 23 shards after that which I bundled up into a big shard.bin file. Then put it into the assets folder and loaded it the way you have shown in the video. However, when I try to run the app on my phone it gives me the error
Failed building JavaScript bundle. assets\group1-shard.bin: Cannot read property 'length' of undefined
I have tried searching a lot for this issue and couldn't find any resolutions.
My project is also an expo managed project and I have configured my metro.config.js the exact way shown in the video.
Please help me with this issue. I really need it. Thank you.
Maybe you can download my github project and try loading it?
@@chirpieful I did that and your project works beautifully. I just don't understand why am I still getting an error when I am trying to do the same thing with a different model.
@@chirpieful Hey, Sooo... after a lot of trying and refactoring I have managed to load the style transfer model. Get images from the user and also convert them into tensors properly, but I don't know how I can pass two tensors to the model. Any idea on how I can do that. I have tried passing the tensors in an array, but it doesn't seem to work.
@@shantanubadve4668 call the model.predict function?
@@chirpieful Yes I did that, called the model.predict then passed it an array of two tensors, it didn't work caught an error in the try catch block.
Unknown op 'MirrorPad'. File an issue at github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()
Any idea what this is?
Hi I checked and it says tensorflowJs not support Keras custom layer model we retrained by myself is it real???🥲
I don't think so.. I deployed my own custom model successfully.
Able to send me the link?
@@chirpieful "TensorFlow.js Layers currently only supports Keras models using standard Keras constructs. Models using unsupported ops or layers-e.g. custom layers, Lambda layers, custom losses, or custom metrics-cannot be automatically imported, because they depend on Python code that cannot be reliably translated into JavaScript. " stated in www.tensorflow.org/js/tutorials/conversion/import_keras
@@chirpieful Possible Unhandled Promise Rejection (id: 6):
Error: Unknown layer: KerasLayer. This may be due to one of the following reasons:
1. The layer is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
2. The custom layer is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().
And this is the error shown in my case, is there any ways I can solve it?QAQ Thanks anway
@@tsangshingman Seems like you can't use custom tensorflow layers. Use keras layers only.
Thank you..And one more.. Can u share us the presentation file?!
Here you go: docs.google.com/presentation/d/1dBnfJ6iZhql-FjzAQF7sdK1mhptnOTJLYAd9pvgZSYA/edit?usp=sharing
@@chirpieful Extremely thanks to you! I got stuck for a month with looking the tutorial like this to learn!I have additional question...do you have the presentation file for the video you tutor about building project with python..step to work with python..? thank you!
@@nguyennam9325 No worries, I was stuck too. That's why I decided to make this video to help everybody :)
@@chirpieful thanks bro!
Hi Oh Yicong
Thanks for the tutorial. It taught me how to deploy a custom built model with react-native. However I am facing a few issues with your model. I downloaded the code from github and did an expo build. I tried to run on android emulator. Nothing happens when I press Predict button. I find the following error
2021-06-03 23:29:54.773 16614-16755/com.sankarai.aiapp I/ReactNativeJS: [-] Unable to load image2021-06-03 23:29:54.773 16614-16755/com.sankarai.aiapp I/ReactNativeJS: [-] Unable to load image
The second problem I am having is in the classifier app I am developing. I used your code as the baseline. The model predict output is zero for all the classes when it should be some decimal value of probabilities. I verified that this is not due to model as I am experiencing same behaviour with your model as well for 2 classes. Further I commented out the face detection part in your code and fed the image directly to the model. The results for both classes is again zero (ie Result[0] and Result[1] you are comparing to decide if there is a face mask or not). I cant seem to figure out if there is something missing in my environment. Can you please help?
Mhmm.. if everything is zero, I suspect that the image is not loaded into the model at all. Do check your input, make sure that there are values in it.
@@chirpieful I am passing the tensor after resizing and reshaping o 4 dimensions. In fact it complained when I did not reshape saying that 4 dimensions are expected. So I certainly know that the input has been taken. I also tried to feed a tensor of ones and zeros. Still same result. Is there any way of verifying if the image is loaded?
@@sankaraniyer4054 you need to print out the input tensors before feeding into the model
@@chirpieful I have printed the tensor fed to the model. It is as follows.
Tensor
[[[[0.654902 , 0.8039216, 0.5176471],
[0.6470588, 0.7960784, 0.509804 ],
[0.6431373, 0.7921569, 0.5058824],
...,
[0.5568628, 0.7568628, 0.2588235],
[0.5568628, 0.7568628, 0.2588235],
[0.4901961, 0.6901961, 0.1921569]],
[[0.6588235, 0.8078431, 0.5215687],
[0.6470588, 0.7960784, 0.509804 ],
[0.6352941, 0.7843137, 0.4980392],
...,
[0.5647059, 0.7647059, 0.2666667],
[0.5529412, 0.7529412, 0.254902 ],
[0.4823529, 0.682353 , 0.1843137]],
[[0.6627451, 0.8117647, 0.5254902],
[0.6392157, 0.7882353, 0.5019608],
[0.6196079, 0.7686275, 0.4823529],
...,
[0.5568628, 0.7647059, 0.254902 ],
[0.5333334, 0.7411765, 0.2313726],
[0.454902 , 0.6627451, 0.1529412]],
...
[[0.3764706, 0.572549 , 0.145098 ],
[0.3882353, 0.5843138, 0.1568628],
[0.3921569, 0.5882353, 0.1529412],
...,
[0.5450981, 0.7372549, 0.3333333],
[0.5450981, 0.7372549, 0.3333333],
[0.5450981, 0.7372549, 0.3333333]],
[[0.3764706, 0.572549 , 0.145098 ],
[0.3882353, 0.5843138, 0.1568628],
[0.3921569, 0.5882353, 0.1529412],
...,
[0.5450981, 0.7333333, 0.3411765],
[0.5450981, 0.7333333, 0.3411765],
[0.5450981, 0.7333333, 0.3411765]],
[[0.3803922, 0.5764706, 0.1490196],
[0.3882353, 0.5843138, 0.1568628],
[0.3921569, 0.5882353, 0.1529412],
...,
[0.5450981, 0.7333333, 0.3411765],
[0.5450981, 0.7333333, 0.3411765],
[0.5450981, 0.7333333, 0.3411765]]]]
I still get Zero predictions.
Insect Class Prediction Result Tensor {
"dataId": Object {},
"dtype": "float32",
"id": 297,
"isDisposedInternal": false,
"kept": false,
"rankType": "2",
"scopeId": 1,
"shape": Array [
1,
102,
],
"size": 102,
"strides": Array [
102,
],
} 0.78978 0.14285714285714285
INFO
13:30
[+] Insect Class Prediction done Insect class Float32Array [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
]
I also found that resizeBilinear returns a tensor of zeros.
Appreciate any help in troubleshooting this
I finally verified that I get correct when I enable remote debugging making use of chrome debugging tools. I get zeros when I stop remote debugging!
Hi, I've just sent you an email. Would appreciate a response :)