ml5.js: Image Classification with MobileNet

75 thoughts on “ml5.js: Image Classification with MobileNet

  1. Hey I just watched your entire video and its great!
    I tried to recreate it but i got an error like this: DOMException: Failed to execute 'texImage2D' on 'WebGL2RenderingContext': The image element contains cross-origin data, and may not be loaded.

    do you have a way to fix this?

  2. Hi Daniel!

    I have been trying to get your attention unsuccessfully, you are a busy person , I know, I have a perhaps small request, and that is: Would you entertain the idea of developing a jigsaw puzzle algorithm to divide or cut a picture into the classic puzzle pieces pls.?


  3. Love your videos, been following for a while and learning tons. Thanks for putting this kind of stuff out there! Do you think the different probabilities in the puffin guess was because the puffin image aspect ratio might've been changed when you resized it to the canvas?

  4. I just got to the 4:41 where you were wondering if all the probabilities need to add up to 100%, and I'm not sure they always do. For example, if the model has an entry for both "Dog" and "Bloodhound", it could be 100% sure that the current image is a dog, but only 80% sure that it's a bloodhound, or something like that.

  5. Hi Great tutorial, is it possible to use the training with ml5 library or use the custom trained model in it?

  6. Hi! I am encountering some sort of error and cannot find any documentation to help me out. Using chrome or safari, I am getting the same result set every time a different image is loaded. This result set is : velvet, window screen and syringe, all with extremely low probabilities.
    I have not been able to fix this issue (I have even copy-pasted the html example from the ml5js page with no success). Please help!

  7. I think you're getting different results 'cause if you're 100% sure it's a dog on a picture an 0% it's a cat it is indeed 100% a dog, but if you think that it has a 70% chance being an alligator and 30% being a crocodile you can say that (by just taking the average of results which is really bad statistically most of the times) it has a 50% chance of being an alligator (favorable to alligator for obviously having the highest rating between all the results)

  8. Great tutorial!! I made a Chatbot based on Eliza and incorporated MobileNet so the bot can see.. Fun stuff, I'm adding face recognition later this week. You can see it on github and at
    Also, maybe the reason for the different prediction confidence values for the Oystercatcher is the canvas size or image resize was different between the two tests.

  9. when you are using the new firefox developer browser you wont need a server to run p5 or any other js library 🙂

  10. Hello , man i enjoy watching your videos , it 's entertaining and full of informations that i need , so my question is : is there any other library that make me able to use ml5.js , because i m not familiar with p5.js ? thanks

  11. Love these tutorials -thanks! Just a quick question: say you have a program/website where a user can upload their own photo to be classified by the MobileNet model (like on the ml5.js website) how ‘safe’ is that? Does MobileNet (or the website) store a record of the image in any way after using it, for example, are user-uploaded images encrypted etc?

  12. Turdus migratorius? Wow, scientific names can be harsh.
    What did the poor bird do to whoever came up with that name? XD

  13. It can tell you that you are a snorkel, but it cannot tell you why. There are decisions, but no reasons. Dan Shifman is the best software teacher on YouTube.

  14. my console says:
    Use of the orientation sensor is deprecated. p5.js:48187:6
    Use of the motion sensor is deprecated. p5.js:48187:6

  15. I have great respect for the time and energy you put into sharing so many "chucks of knowledge" in such a wide range of domains. Thank you.

  16. This is the first video i watched and it's so cool. i'm newbie so can you tell me how do you build this in server??

  17. If you want to implement ml5.js MobileNet model with React.js, check this article:

  18. Hi, I know this is not a callback/asynchronous programming video. I still want to clarify one thing. Since your image reading code is asynchronous and modelReady code is also asynchronous, what if your image took longer to be read i.e. lets say you were reading it over the network or something. And your model got ready before your imageReady, would there be any errors? I am asking this is because if you tried predicting puffin before it was even ready, would Javascript be smart enough to handle it?

  19. whenever i try to run the code i get an error in the console that says failed to execute 'texImage2D' on 'WebGL2RenderContext': The image element contains cross-origin dad , and may not be loaded.

    The issue is that i used the same code and i used the same picture so i dont know what is wrong

  20. I got this error "DOMException: Failed to execute 'texImage2D' on 'WebGL2RenderingContext': The image element contains cross-origin data, and may not be loaded."

  21. Hey Dan, trying out your code of this class in p5.js and kept getting the error "Uncaught ReferenceError: ml5 is not defined ". I checked the code and it looked right so I went to your git hub page with the code, copied it and pasted it in the p5 editor and still got the same error. What should I add to make the code work? P.S. love your videos.

  22. Could you also explain how to retrain a preexisting model using newer images ? Also, I know you love pure javascript but maybe a couple video using tensorflow and ml5 on a framework like React or Angular would be really appreciated ! Thanks!

  23. Maybe js is the future for ML/classification cause it's closests to the internet than any other language..The database to handle with is enormous..maybe it's more a matter of copyright and privacy that's is not booming?.I was playing with google colab ,kaggle and tensorflow but the inputdata is always limited..So…Or i'm I wrong…I!m more an artist than a programmer so i don't see it that clearly..Keep up the good work ..It's great !!(and fun)

  24. tf-core.esm.js:17 Uncaught TypeError: Y is not a function
    at new e (tf-core.esm.js:17)
    at Function.e.make (tf-core.esm.js:17)
    at nt (tf-core.esm.js:17)
    at (tf-core.esm.js:17)
    at Object.<anonymous> (postprocess.js:11)
    at n (bootstrap:19)
    at Object.<anonymous> (index.js:18)
    at n (bootstrap:19)
    at Object.<anonymous> (index.js:12)
    at n (bootstrap:19)

  25. how to run the code in server mode..???
    bcz while I'm opening with index.html in browser its not opening with classification work??>

  26. May, 2019. In the p5js editor image is being loaded automatically, only with the image() command.

  27. Hi there,

    I want to know, is there a way to use object or image recognition on internet or website like on Amazon or Walmart to product images recognition, etc, rather than using real-time object detection via webcam. please reply

  28. When I run the above code, I get the error "sketch.js:18 Error: Failed to link vertex and fragment shaders.". When I googled it and got a solution as "Same here, solved by disable gpu backend _tfengine.ENV.set('WEBGL_PACK', false) before you do anything with tensorflow. An other option would be upgrade your graphic card driver~" . But I do not know how to apply it. Anyone got this error and resolved it ?

  29. In case anyone wants to use MobileNet locally (offline), it is possible to download a local copy of the model json file and reference its path, see on GitHub a repository named "ml5-data-and-models-server"

  30. I can't seem to get this to work with version 0.4.3… (with 0.1.1 yes)

    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at 2. (Reason: CORS request did not succeed).



    if i try to go to

    i get “We’re having trouble finding that site.”

    does this mean the mobilenet server is down ?
    is anyone else having the same problem ?

Leave a Reply

Your email address will not be published. Required fields are marked *