Closed UjjwalKaur closed 2 months ago
Hi, @UjjwalKaur
Thank you for bringing this issue to our attention, if possible could you please help us with your model in zip file format and minimal code snippet to replicate the same behavior from our end to investigate this issue further from our end as soon as possible ?
Thank you for your cooperation and patience.
@gaikwadrahul8 Here's the zip file of the tensorflow.js model tfjs_model.zip Here's my index.html code index.html.zip I have also used a haarcascade_frontal_face file but that's irrelevant to this query. The emotion_model.h5 file (the original tensorflow keras model) is too large to be uploaded
Hi, @UjjwalKaur
I apologize for the delay in the response and I see {"format": "layers-model", "generatedBy": "keras v3.4.1", "convertedBy": "TensorFlow.js Converter v4.20.0", "modelTopology": {"keras_version": "3.4.1", "backend": "tensorflow"
in the model.json
file so it's using the Keras 3
so may be it's causing the issue so could you please give it try with Keras 2
version because Keras 2
is compatible with tensorflowjs_converter
If you install latest version of tensorflowjs
then by default it will install Tensorflow 2.16.2
and Keras Version: 3.4.1
(Keras 3) which does not support with tensorflowjs_converter
as far I know so you'll have to downgrade TensorFlow version to 2.15.0 where it will use Keras Version: 2.15.0 please refer this gist-file
Should you want tf.keras to stay on Keras 2 after upgrading to TensorFlow 2.16+, you can configure your TensorFlow installation so that tf.keras points to tf_keras
. To achieve this:
Make sure to install tf_keras
. Note that TensorFlow does not install it by default.
Export the environment variable TF_USE_LEGACY_KERAS=1
.
There are several ways to export the environment variable:
TF_USE_LEGACY_KERAS=1
to your .bashrc
file. That way the variable will still be exported when you restart your shell.import os
os.environ["TF_USE_LEGACY_KERAS"] = "1"
These lines would need to be before any import tensorflow statement.
Thank you for your cooperation and patience.
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.
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 When I convert my model from keras tensorflow to tensorflow.js, I am getting this error - Uncaught (in promise) Error: Provided weight data has no target variable: sequential/conv2d/kernel
Upon reading some suggestions online, I tried to use tensorflow version 2.15.0 instead of 2.16.0 but it didn't work. I even thoroughly checked the names of weights in my model.json file and the names are exactly the same as the weight names of my model. Here's the weightsManifest block in my model.json file
{"weightsManifest": [{"paths": ["group1-shard1of3.bin", "group1-shard2of3.bin", "group1-shard3of3.bin"], "weights": [{"name": "sequential/conv2d/kernel", "shape": [3, 3, 1, 32], "dtype": "float32"}, {"name": "sequential/conv2d/bias", "shape": [32], "dtype": "float32"}, {"name": "sequential/conv2d_1/kernel", "shape": [3, 3, 32, 64], "dtype": "float32"}, {"name": "sequential/conv2d_1/bias", "shape": [64], "dtype": "float32"}, {"name": "sequential/conv2d_2/kernel", "shape": [3, 3, 64, 128], "dtype": "float32"}, {"name": "sequential/conv2d_2/bias", "shape": [128], "dtype": "float32"}, {"name": "sequential/conv2d_3/kernel", "shape": [3, 3, 128, 128], "dtype": "float32"}, {"name": "sequential/conv2d_3/bias", "shape": [128], "dtype": "float32"}, {"name": "sequential/dense/kernel", "shape": [2048, 1024], "dtype": "float32"}, {"name": "sequential/dense/bias", "shape": [1024], "dtype": "float32"}, {"name": "sequential/dense_1/kernel", "shape": [1024, 7], "dtype": "float32"}, {"name": "sequential/dense_1/bias", "shape": [7], "dtype": "float32"}]}]}