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
Supporting p5's preload() for loading models #92
Comments
We are not supporting p5 preload method but all examples do work with p5 at the moment. Either by setting this up the ml5 methods before or inside the Not sure if we need to implement a custom register for the |
Looking at the Image Classifier example does let classifier;
let img;
function preload() {
classifier = ml5.imageClassifier('Mobilenet');
img = loadImage('bird.jpg');
}
function setup() {
createCanvas(400, 400);
image(bird, 0, 0);
classifier.predict(img, gotResult);
}
function gotResult(results) {
createPl(results[0].className);
} |
The let lstm;
function preload() {
lstm = ml5.LSTMGenerator('models/nietschze/');
}
function setup() {
noCanvas();
lstm.generate({ seed: 'Hello, my name is' }, gotResult);
}
function gotData(result) {
createP(result);
} |
It does support a callback. See https://ml5js.org/docs/ImageClassifier#syntax I'm going to investigate a more formal integration with p5 |
Any update on support for p5's |
I think if p5 is already loaded, we can just need to make sure that the If we are doing standalone btw, in LSTM Example Page, there is an error that |
Hi @NHibiki, the idea here is not to create a new There is information in the p5 developer docs here: Use registerPreloadMethod() to register names of methods with p5 that may be called in preload(). Re: |
I'm happy to see this moving along. |
@shiffman Wow, I have read the document about But would there be a scenario that some users only use |
Hi @NHibiki, I think if someone is using vanilla JavaScript without p5 then the standard asynchronous methodology for loading a model will be enough. The concept of |
@EmmaGoodliffe - I think Thanks for going through all these issues! |
@joeyklee after reading the implemented code of |
This quick sketch shows that the when run with |
Thanks for this wonderful discussion and everyone's contributions! I think it makes sense to support |
Hi All! As most of our models now abide by this standard, I will close this issue now. We can revisit this for specific model needs as they arise in the future. Thank you for your participation all! |
For beginners it's wonderful to support p5's
preload()
. I noticed some of our examples already includepreload()
for loading models. This may, in fact, be working just fine but I am opening an issue as a reminder to check if they are functioning correctly and that we are conforming to the p5 preload system. Here are some relevant links:loadBytes()
method for p5I think we would need something in the ml5 library that checks for the existence of p5 and if it does exists registers our methods with
registerPreloadMethod()
?Apologies if this is in the codebase somewhere already I searched and didn't see it.
The text was updated successfully, but these errors were encountered: