I’m trying to get the Image Classifier demo to work (using a local server) but I keep getting a “NetworkError when attempting to fetch resource” error…
It apparently has something to do with CORS but I can’t seem to able to fix it.
let test;
let url = 'https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2/model.json?tfjs-format=file';
function preload() {
test = loadJSON(url);
}
function setup() {
print(test);
}
function draw() {
}
also can see it in win 10 / firefox and chrome browser
but i have also the firefox
let test;
let done=false; //Ensures text is only printed once per click
function preload() {
let url = 'https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2/model.json?tfjs-format=file';
//REFERENCE httpGET: https://p5js.org/reference/#/p5/httpGet
httpGet(url, 'text', false, function(response) {
test = response;
}
);
}
function setup() {
createCanvas(640, 480);
}
function draw() {
if (mouseIsPressed) {
if (done==false) {
fill(180);
text("Hello " + test, width/2, height/2);
print(test);
done=true;
}
} else {
done=false;
}
}
Just inspect the console logs. Then press once in the canvas of your p5js sketch and inspect the logs and you should see there the output that you need to process.