question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The shape of dict['ToFloat'] provided in model.execute(dict) must be []

See original GitHub issue

When using the latest model created by automl for tensorflowjs using https://cloud.google.com/vision/automl/object-detection/docs/edge-quickstart exactly.

Has anyone else seen this issue with exporting model from automl for tensorflowjs?

When running const predictions = await model.detect(img, options);

Getting the following error:

util.js:109 Uncaught (in promise) Error: The shape of dict['ToFloat'] provided in model.execute(dict) must be [], but was [1,1280,1920,3]
    at Ev (util.js:109)
    at graph_executor.js:543
    at Array.forEach (<anonymous>)
    at e.t.checkInputShapeAndType (graph_executor.js:534)
    at e.<anonymous> (graph_executor.js:332)
    at u (runtime.js:45)
    at Generator._invoke (runtime.js:274)
    at Generator.forEach.e.<computed> [as next] (runtime.js:97)
    at Um (runtime.js:728)
    at o (runtime.js:728)

Using

"@tensorflow/tfjs": "^2.6.0",
"@tensorflow/tfjs-automl": "^1.0.0"

Full code

<script src="/node_modules/@tensorflow/tfjs/dist/tf.min.js"></script>
<script src="/node_modules/@tensorflow/tfjs-automl/dist/tf-automl.min.js"></script>
<img id="img" src="salad.jpg">
<script>
    async function run() {
        const model = await tf.automl.loadObjectDetection('/model/model.json');
        const img = document.getElementById('img');
        const options = { score: 0.5, iou: 0.5, topk: 20 };
        console.log(model.dictionary);
        const predictions = await model.detect(img, options);
        console.log(predictions);
        // Show the resulting object on the page.
        const pre = document.createElement('pre');
        pre.textContent = JSON.stringify(predictions, null, 2);
        document.body.append(pre);
    }
    run();
</script>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
pyu10055commented, Oct 14, 2020

@ghafran This has been fixed recently on the AutoML side, I will update this thread when the changes has been deployed. You might need to retrain the model on the autoML side.

0reactions
ghafrancommented, Oct 21, 2020

This seems to be fixed now. Its working after re-training and exporting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The shape of dict['ToFloat'] provided in model.execute(dict ...
This particular error is telling me that my shape must be an empty array or empty shape. Is that even possible? If this...
Read more >
Error: The shape of dict['input_tensor'] provided in model ...
Hi, I converted my saved model to model json using ... Error: The shape of dict['input_tensor'] provided in model.execute(dict) must be [1 ...
Read more >
The Shape Of Dict['Tofloat'] Provided In Model.Execute(Dict ...
This particular error is telling me that my shape must be an empty array or empty shape. Is that even possible? If this...
Read more >
[Solved]-Error: The shape of dict['ToFloat'] provided in model ...
Coding example for the question Error: The shape of dict['ToFloat'] provided in model.execute(dict) must be [-1,-1,-1,3], but was [200150,3]-React Native.
Read more >
The shape of dict['image'] provided in model.execute(dict ...
Is this a custom/modified mobilenet model? The error is letting you know that input named image must be a scalar (shape []) instead...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found