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.

[tfjs-models] - Inconsistent detections

See original GitHub issue

TensorFlow.js version

Versions:

    "@tensorflow-models/coco-ssd": "^2.0.2",
    "@tensorflow/tfjs-converter": "^1.7.2",
    "@tensorflow/tfjs-core": "^1.7.2",

Browser version

Chrome: 81.0.4044.92 (Official Build) (64-bit)

The issue is a little weird but it happens all the time.

How to replicate

Send b64 image for Object detection… and it has 0 detections

console.log output:

<img src=​"data:​image/​jpeg;​base64,............... b64 text" width=​"500" height=​"375">​
Dropzone.svelte:75 number of detections:  0
Dropzone.svelte:79 upload-and-predict: 145.814208984375ms

Same b64 image for object detection… and!

console.log output:

<img src=​"data:​image/​jpeg;​base64,............... b64 text" width=​"500" height=​"375">​
Dropzone.svelte:75 number of detections:  1
Dropzone.svelte:79 upload-and-predict: 127.974853515625ms

and it has 1 detection… This happens 100% of the time.

Extra Note: It has to be the same image twice. If i keep adding different images it wont predict until i load the same one a second time. Seems like it needs a second time around to get a detection in place.

Code

    import * as cocoSsd from '@tensorflow-models/coco-ssd';
    .
    .
    .
    const baseModel = 'mobilenet_v1';
    model = await cocoSsd.load({ base: baseModel });
    const detectionTest = new Image();
    detectionTest.src = b64Image; // This is b64 string like in the screen shot
    detectionTest.width = 500; // Have to manually set this... or it leads to a diff bug 
    detectionTest.height = 375; // Have to manually set this... or it leads to a diff bug
    bug is this: https://github.com/tensorflow/tfjs/issues/322
    const result = await model.detect(detectionTest);
    console.log('number of detections: ', result.length);
   .
   .
   .

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
rthadurcommented, Apr 10, 2020

@badman-rodriguez thanks for the info , it looks like you are using a java script framework(svelte),I tried original coco-ssd example it is working as expected , I believe this is not a bug or feature request related to tfjs which we can help here , I would suggest you ask this question in stack-overflow with tag ‘tensorflow.js’ , thank you

0reactions
badman-rodriguezcommented, Apr 13, 2020

that’s easy to blame the framework… once i solve the problem. will post the actual solution here. Figured an expert with this package might have some expect insight on some causes…

welp, appreciate the due diligence in the investigation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tensorflow.js inconsistent prediction, returns 0 or works as ...
I'm trying to do a simple Tensorflow.js linear model but I get inconsistent results. It will either return 0 for any input value...
Read more >
Custom object detection in the browser using TensorFlow.js
In this post, we are going to develop an end-to-end solution using TensorFlow to train a custom object-detection model in Python, ...
Read more >
Fast client-side ML with TensorFlow.js, by Ann Yuan (Google)
TFJS defines an API for neural network operations, ... comes to inference on face detector, a much smaller model with only around 20...
Read more >
Custom Real-Time Object Detection in the Browser Using ...
TensorFlow 2 provides 40 pre-trained detection models on the COCO 2017 ... supported so some models can be incompatible with TensorFlow.js ...
Read more >
Chapter 5. Transfer learning: Reusing pretrained neural ...
What transfer learning is and why it is better than training models from ... How to use transfer learning to train a simple...
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