ml5js / ml5-next-gen

Repo for next generation of ml5.js: friendly machine learning for the web! 🤖
https://ml5js.org/
Other
77 stars 23 forks source link

imageClassifier not working in v1.0.1 #183

Open aswyatt opened 3 months ago

aswyatt commented 3 months ago

The image classifier does not seem to be working in v1.0.1 - it returns the same results regardless of the image. I followed the tutorial on the getting started page. If I change the model, I get a different result (but always the same result for a given model with different images). The image classifier is working fine in version 0.12.

ziyuan-linn commented 3 months ago

Hi @aswyatt, thank you for opening this issue!

Do you mind sharing your p5 sketch so we can narrow down the issue?

In the meantime, here is an example sketch for ImageClassifier that is working on my end: https://editor.p5js.org/ml5/sketches/pjPr6XmPY. Feel free to try it out and let me know whether it works for you!

aswyatt commented 3 months ago

Sketch: https://editor.p5js.org/aswyatt/sketches/7XSXf4R0F

It's pretty much identical, and the problem appears to be the interaction with ML5 and Chrome, rather than the sketch. So if I run my sketch (or yours) on my phone (Android Chrome Beta 128.0.6613.14), they both worth fine, although I receive a warning "Initialization of backend webgpu failed ...", but it works. However, on my desktop in either Chrom (127.0.6533.89) or Edge (127.0.2651.74), it clearly does not classify the image for my script. I cannot run your script in Chrome - it says "TypeError: failed to fetch" when trying to load the image - there seems to be some kind of permissions issue. On Edge, yours runs but doesn't classify the image either (says its a spotlight).

ziyuan-linn commented 2 months ago

Hi @aswyatt! Sorry for the late reply. Were you able to solve the problem?

I tried your sketch in Chrome on both Windows 11 and macOS and everything works fine. It also works in Edge on Windows. I'm using the same Chrome version as you, but I can't reproduce the error.

ImageClassifier running in p5 web editor

If you haven't already, perhaps try clearing your browser cache?

The "TypeError: failed to fetch" error on my sketch may be related to a p5 Web Editor CORS issue: https://github.com/processing/p5.js-web-editor/issues/3156