Comments (5)
Hi, @Infiniteskys
Thank you for bringing this issue to our attention and please give it try with below code snippet and see is it working as expected or not ? Please refer official documentation of asyncStorageIO to save and load the model to/from async storage
import * as tf from "@tensorflow/tfjs";
import { asyncStorageIO } from "@tensorflow/tfjs-react-native";
export const loadModel = async () => {
try {
await tf.ready();
const model = await tf.loadGraphModel("https://test_model/model.json");
console.log("Model loaded.");
model.summary();
// Save the model to AsyncStorage
const savedModel = await model.save(asyncStorageIO('customs'));
console.log("Model saved to AsyncStorage");
// Load the model from AsyncStorage
const loadedModel = await tf.loadLayersModel(asyncStorageIO('customs'));
console.log(loadedModel == model); // This might not be true due to model serialization
return loadedModel;
} catch (e) {
console.error("Error:", e);
return null;
}
};
If issue still persists please let us know and if possible please help us with your Github repo along with model and complete steps to run code to replicate the same behaviour from our end.
Thank you for your cooperation and patience.
from tfjs.
Hi @gaikwadrahul8 ,
I had tried it but it still not working and show the error that layer improper config format.
I believe the json file we convert is a graph model, I had tried to use Loadgraphmodel function, but I can only load from the Website URL but not the asynstrongIO.
from tfjs.
If I have the function as below, it will show the error: Based on the provided shape, [4.2],the tensor should have 8 values but has 1.
import * as tf from "@tensorflow/tfjs";
import { asyncStorageIO } from "@tensorflow/tfjs-react-native";
export const loadModel = async () => {
try {
await tf.ready();
const model = await tf.loadGraphModel("https://test_model/model.json");
console.log("Model loaded.");
// Save the model to AsyncStorage
const savedModel = await model.save(asyncStorageIO('customs'));
console.log("Model saved to AsyncStorage");
// Load the model from AsyncStorage
const loadedModel = await tf.loadGraphModel(asyncStorageIO('customs'));
return loadedModel;
} catch (e) {
console.error("Error:", e);
return null;
}
};
from tfjs.
Hi, @Infiniteskys
If possible could you please help us with your model file in zip format along with complete steps to replicate the same behavior from our end to investigate this issue further ?
Thank you for your cooperation and patience.
from tfjs.
Hi @gaikwadrahul8 ,
Here is the test model other friend train at the service side and convert it at the service.
test_model.zip
I had also test to use the location directly.
const loadedModel = await tf.loadLayersModel('/moblientclient/assest/model/test_model/model.json');
But it will show error the network request fail. But in this case, I dont have any idea how to save the model if there is a update version at the service.
Thank you.
from tfjs.
Related Issues (20)
- Question: is the Windows tensorflow binary / dll used in tfjs-node compiled with support for zenDNN optimisations? HOT 2
- Standard layers (like `tf.layers.dense`) fail to report their trainable weights, when used from within a custom layer HOT 4
- Error installing @tensorflow/tfjs-node at WSL Ubuntu HOT 3
- Bug when stacking LSTM HOT 4
- Tensor construction fails for the majority of TypedArray types HOT 1
- Trouble loading a saved model in tfjs-node, "Op type not registered 'DisableCopyOnRead'" HOT 3
- tfjs-node - upgrade tar >=6.2.1 HOT 3
- Undefined variable tensorflow-library-target in binding.gyp HOT 4
- tensorflowjs_converter: NotImplementedError: numpy() is only available when eager execution is enabled HOT 9
- tensorflowjs_converter on .keras file messes up weights HOT 6
- Safari webworker `Error when getting WebGL Context` HOT 4
- tfjs-node-gpu warnings (not running in GPU mode) HOT 2
- Model with softmax output layer not outputing probabilities but just 1 and 0 HOT 4
- Model Face Detection Confidence Score Output or Minimum Confidence Score Threshold
- model.executeAsync fails when loading multiple converted TF-DF models HOT 4
- TensorFlowJS fails reliably on Intel GPU running Windows, otherwise succeeds HOT 1
- Error when a module try to install tensorflow HOT 4
- I can't install @tensorflow/tfjs-node in my project HOT 5
- Finish placeholder features: einsum gradients, conv1d causal padding HOT 3
- Tfjs pose detection not working with newer Android devices (12, 13, 14) HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tfjs.