Ml5 NetworkError

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.

“Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2/model.json?tfjs-format=file. (Reason: CORS request did not succeed)”

Any ideas ???

1 Like

yacdn.org

1 Like

I realize that it is a CORS issue but I can’t fix it.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2/model.json?tfjs-format=file. (Reason: CORS request did not succeed).

if i try to go to
https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2/model.json?tfjs-format=file
i get “We’re having trouble finding that site.”

Any ideas ?

here ok ( using the p5.js online editor )

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

CORS Everywhere

extension installed, but not needed here.

Thanks but using your test I still get :

GET https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2/model.json?tfjs-format=file net::ERR_NAME_NOT_RESOLVED

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

When you hit that url, you get redirected to https://storage.googleapis.com/tfhub-tfjs-modules/google/imagenet/mobilenet_v2_100_224/classification/2/model.json

Kf

but it doesn’t redirect

The following code produces the same output as from this link:
https://storage.googleapis.com/tfhub-tfjs-modules/google/imagenet/mobilenet_v2_100_224/classification/2/model.json

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.

Kf

I guess what I’m trying to say is that within the ml5 library :
https://unpkg.com/ml5@0.4.3/dist/ml5.min.js

the link to Mobilenet doesn’t work anymore :
https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2/model.json?tfjs-format=file

Is anyone else experiencing this problem ?