object-detection-react icon indicating copy to clipboard operation
object-detection-react copied to clipboard

Tensor must have a shape comprised of positive integers but got shape [1917,]

Open mingsoohea opened this issue 4 years ago • 9 comments

I followed cloud.annotations.ai to train a custom model for tensorflow.js. After cloning this project and copy the model_web to the public folder, I run npm install then npm run start.

The local page is showed with an error when detectFromVideoFrame: Error: Tensor must have a shape comprised of positive integers but got shape [1917,]. at g (index.esm.js:17) at index.esm.js:17 at Array.forEach (<anonymous>) at Q (index.esm.js:17) at kn (index.esm.js:17) at Object.Dn [as tensor2d] (index.esm.js:17) at index.esm.js:500 at index.esm.js:17 at t.scopedRun (index.esm.js:17) at t.tidy (index.esm.js:17) at Object.Ke [as tidy] (index.esm.js:17) at runObjectDetectionPrediction (index.esm.js:499) at async Object.detect (index.esm.js:556)

After digging a bit into the source code, I found this strange: Untitled

Untitled1

Untitled2

Untitled3

As you see, the scores and boxes have been swapped together. Is it intended?

mingsoohea avatar Nov 26 '20 10:11 mingsoohea

@bourdakos1

mingsoohea avatar Nov 26 '20 10:11 mingsoohea

This normally means you didn’t have enough training data

bourdakos1 avatar Nov 26 '20 13:11 bourdakos1

I used 200 images to annotate on cloud.annotations.ai. How many images should I use at least? From the last screenshot, result[1].shape only have 3 components [1, 1917, 1] but the code tries to get result[1].shape[3] Is it make sense?

mingsoohea avatar Nov 26 '20 23:11 mingsoohea

200 hundred images might be enough, but it more depends on how many labels and how many objects per label

bourdakos1 avatar Nov 27 '20 00:11 bourdakos1

1 label for all 1 object per image only.

mingsoohea avatar Nov 27 '20 06:11 mingsoohea

Try adding a second label

bourdakos1 avatar Nov 27 '20 13:11 bourdakos1

Did it help to add more images or an additional lable? Because i have the same error :D

Roger92 avatar May 07 '21 12:05 Roger92

I'm having the same error. Did adding more images help? I have 3 labels and 200 images for each of them

sebaspv avatar Oct 02 '21 23:10 sebaspv

Does anybody have a working model_web so I can make some tests?

menuRivera avatar Nov 21 '21 02:11 menuRivera