TFJS-object-detection
TFJS-object-detection copied to clipboard
[Solved] TensorList shape mismatch: Shapes -1 and 3 must match
After exporting the model and testing that it works properly, I've converted it to Tensorflowjs following your steps. I've loaded it to the browser and I can't find the way to let it predict an image,
Here's the code:
const process_input = (image ) => { const tfimg = tf.browser.fromPixels(video_frame).toInt(); const expandedimg = tfimg.transpose([0, 1, 2]).expandDims(); return expandedimg; }; const image = document.getElementById('image'); const preImage = process_input (image); tf.engine().startScope(); model.executeAsync(testImg).then(predictions => { console.log(predictions); tf.engine().endScope(); });
Right after that, I got an error saying:
Unhandled Rejection (Error): TensorList shape mismatch: Shapes -1 and 3 must match
I have the same issue
I have the same problem
The problem was with TensorFlowJS 3.0.0 after upgrading to 3.1.0 I can confirm all work well, just when converting the model - do not use the converter wizard as it adds the argument --control_flow_v2=True which causes a different problem.
Well noticed, @nirchetrit! Thanks for your contribution
The problem was with TensorFlowJS 3.0.0 after upgrading to 3.1.0 I can confirm all work well, just when converting the model - do not use the converter wizard as it adds the argument --control_flow_v2=True which causes a different problem.
please share a saved_model.pb file with me, thanks
Hey, please make sure you are running: "@tensorflow/tfjs": "^3.1.0", "@tensorflow/tfjs-converter": "^3.1.0",
As well tfjs-converter 3.1.0 in your python environment..
For the converter use the following command:
tensorflowjs_converter \
--input_format=tf_saved_model \
--output_format=tfjs_graph_model \
--signature_name=serving_default \
--saved_model_tags=serve \
saved_model \
web_model
Anyway, this is the issue post
Hey, please make sure you are running: "@tensorflow/tfjs": "^3.1.0", "@tensorflow/tfjs-converter": "^3.1.0",
As well tfjs-converter 3.1.0 in your python environment..
For the converter use the following command:
tensorflowjs_converter \ --input_format=tf_saved_model \ --output_format=tfjs_graph_model \ --signature_name=serving_default \ --saved_model_tags=serve \ saved_model \ web_model
Anyway, this is the issue post
i just want a saved_model.pb thanks [email protected]
Hi @nirchetrit , I have encountered the same issue so I followed your solution. To be more specific:
- I have created the virtualenv with tensorflowjs-converter 3.1.0
- I have cloned the app from @hugozanini repository.
- Instead of executing "npm install "I have manually installed tfjs, tfjs-converter, tfjs-node, tfjs-core : all in 3.1.0 version
- I also installed tfjs-data and tfjs-layers as they were listed as necessary when I execute " npm list --depth=0" command
Unfortunately I still can't get it working now with different error: " Unhandled Rejection (TypeError): undefined is not a function (near '...scores[0].forEach...') " .
I am training exact same model on the same data as @hugozanini. My version of model is here: https://raw.githubusercontent.com/TrybusRafalJan/TWM_projekt/main/web_model/model.json
I would much appreciate your help.
Hi @nirchetrit , I have encountered the same issue so I followed your solution. To be more specific:
- I have created the virtualenv with tensorflowjs-converter 3.1.0
- I have cloned the app from @hugozanini repository.
- Instead of executing "npm install "I have manually installed tfjs, tfjs-converter, tfjs-node, tfjs-core : all in 3.1.0 version
- I also installed tfjs-data and tfjs-layers as they were listed as necessary when I execute " npm list --depth=0" command
Unfortunately I still can't get it working now with different error: " Unhandled Rejection (TypeError): undefined is not a function (near '...scores[0].forEach...') " .
I am training exact same model on the same data as @hugozanini. My version of model is here: https://raw.githubusercontent.com/TrybusRafalJan/TWM_projekt/main/web_model/model.json
I would much appreciate your help.
You have you change de index in the boxes, scores and classes variables