Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Darknet image classifier always returns "nematode" #1303

Open
gohai opened this issue Feb 15, 2022 · 4 comments · May be fixed by #1398
Open

Darknet image classifier always returns "nematode" #1303

gohai opened this issue Feb 15, 2022 · 4 comments · May be fixed by #1398
Assignees

Comments

@gohai
Copy link
Member

gohai commented Feb 15, 2022

When running the Darknet image classifier with the latest published version of ml5.js, I am always getting "nematode" as the label with the highest confidence, regardless of input image.

I've tested this with a webcam image, as well as with a static PImage of a bird.

The exact confidence varies slightly, indicating to me that the network is in principal running, and that the input is reaching it. But no matter the input, the output will always be "nematode".

Here's a sketch that demonstrate this issue (as of Feb 15 2022): https://editor.p5js.org/gohai/sketches/Wt1qPNPnq

The same sketch works with "MobileNet" and "DoodleNet" parameters to the image classifier initializer.

@tlsaeger
Copy link
Member

Hi @gohai, I looked into this yesterday and I could not really figure this out. What I found was, that it always picks a certain item from our list of possible things. If I change nematode to my name it only displays my name. It also thinks that nematode is the most likely. I've seen the full list. I try to dig deeper into this. Maybe @shiffman, @bomanimc or @joeyklee have an idea?

@lindapaiste
Copy link
Contributor

lindapaiste commented May 22, 2022

I was cleaning up some of our image-to-tensor conversions today and I noticed that we are going through pre-processing twice for darknet! There is a call to imgToTensor (which resizes and rescales) in the parent ImageClassifier. Then in darknet.js we are preprocessing again. It will end up with tiny values because we are dividing by 255 twice.

We may have the same problem in doodlenet too?

@lindapaiste
Copy link
Contributor

I need to clean up my code before creating a PR but I just want to note that I do have this fixed! 🥳

@lindapaiste lindapaiste linked a pull request May 26, 2022 that will close this issue
@gohai
Copy link
Member Author

gohai commented May 26, 2022

Happy hear - thank you @lindapaiste

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants