ml5js / ml5-data-and-models-server

A repo to download and serve data and models locally allowing ml5 to run without a web connection
29 stars 13 forks source link

Is it posible to load posenet? #7

Open Warholik opened 4 years ago

Warholik commented 4 years ago

Hello!

I used posenet this way:

Is it possible to use it in the same way with your repo offline? If yes how?

Thanks!

joeyklee commented 4 years ago

Hi!

Yes in v0.4.2 it is possible, however it requires a few steps:

  1. Clone this repo: https://github.com/ml5js/ml5-data-and-models-server. Follow the instructions here: https://github.com/ml5js/ml5-data-and-models-server#setup-
  2. In ml5, you'll make sure:
    <script src="https://unpkg.com/ml5@0.4.2/dist/ml5.min.js"></script>

    and in your sketch.js

posenet = ml5.poseNet("http://localhost:5000/posenet", video)

I haven't gotten around to documenting this or making a tutorial, but give this a try and let me know if this works! Thanks!

reza7rm commented 4 years ago

Thanks @joeyklee for this awesome work; Unfortunately I get 404 error, trying to load posenet. I use both http://localhost:5000/posenet and http://localhost:5000/posenet/mobilenet_v1_050/, Still it doesn't work.

stephanschulz commented 4 years ago

same here. I also tried making the path part of the options. like so

let poseOptions = {
    modelUrl: "http://localhost:5000/posenet",
  detectionType: 'single'
};
poseNet = ml5.poseNet(video, poseOptions, modelReady);

I guess I am also a bit unclear about the location of where ml5-data-and-models-server-source needs go in reference to my project folder. right now I have: +--myProject | +--index.html | +--script.js | +--ml5-data-and-models-server-source

I cd to ml5-data-and-models-server-source and call npn run serve

I should also mention that I used the Brackets IDE, which opens a live browser view at http://127.0.0.1:61583/index.html

AndreasRef commented 4 years ago

Anybody got this working? I need to run PoseNet offline for an upcoming installation, so very interested in case someone figured this out :-)

stephanschulz commented 4 years ago

yes I got it running locally.

added this to index.html

  <script src="/libs/p5js/p5-0.9.0/p5.min.js"></script>
        <script src="/libs/p5js/p5-0.9.0/addons/p5.dom.min.js"></script>

        <script src="http://localhost:5000/ml5.min.js" type="text/javascript"></script>

before running my JS project that uses ml5js I did:

AndreasRef commented 4 years ago

Thanks @stephanschulz ! I followed the steps and seem to have downloaded the models + run them via npm, but it returns a 404:

GET http://localhost:5000/ml5.min.js net::ERR_ABORTED 404 (Not Found) sketch.js:21 Uncaught ReferenceError: ml5 is not defined at setup (sketch.js:21)

Any chance I could see your posenet code (html + js), to learn what I did wrong?

stephanschulz commented 4 years ago

maybe the local server that ml5-data-and-models-server starts has a different Port and is not 5000. the terminal should show you what port it uses when you start the npm run thing.

I will put together a simple example in a bit and post it here.

stephanschulz commented 4 years ago
AndreasRef commented 4 years ago

Wow, thank you so much @stephanschulz ! I got it working thanks to your guidance and example 🥳. Really appreciate all your help.

viswongdev commented 3 years ago

I have the same issue, I did exactly same(run the server and using bracket) I even couldn't find the ml5.min.js in the folder so tried to download it from the CDN and put it into the folder but still no luck... Any clues or solutions? Thank you