ml5js / ml5-library

Friendly machine learning for the web! 🤖
https://ml5js.org
Other
6.46k stars 904 forks source link

Fetch data from GitHub repo as JSON doesn't work #1485

Open konvasil opened 5 months ago

konvasil commented 5 months ago

I want to load some data from a JSON file which is stored in GitHub, the data is printed in Chrome's console as expected and as soon as is fetched but when I try to load it for the neural network with loadData(....) it doesn't work.

 //load data from GitHub
    if(key == 'f' && state == 'waiting') {
        const fetchPromise = fetch("myUrl")

        fetchPromise
            .then((response) => response.json())
            .then((raw) => {
                remoteLoad(raw)
            })
    }

function remoteLoad(data){
    console.log(options)
    brain.loadData(data, dataLoaded)
}
shiffman commented 4 months ago

Hi @konvasil, could you try using the newest ml5.js? https://github.com/ml5js/ml5-next-gen

Examples and Docs: https://github.com/ml5js/ml5-next-gen/blob/main/documentation.md https://editor.p5js.org/ml5/collections/pUzWMkdmE

If you still have errors, to help, I think we would need additional information, a link to a simplified sketch in the p5.js web editor would be most helpful. I would also suggest using p5.js preload() function to get the data to send to the neural network.