0

StackOverflow 社区,我是机器学习的新手,尤其是 ml5.js 和 p5.js 库,我遇到了下面的错误,我尝试搜索但仍然无法弄清楚代码有什么问题。希望你能给我一些想法。提前致谢!

我遇到的错误:

Uncaught (in promise) Error: Failed to link vertex and fragment shaders.
    at Zt (tf-core.esm.js:17)
    at t.createProgram (tf-core.esm.js:17)
    at tf-core.esm.js:17
    at tf-core.esm.js:17
    at t.getAndSaveBinary (tf-core.esm.js:17)
    at t.compileAndRun (tf-core.esm.js:17)
    at t.conv2dWithIm2Row (tf-core.esm.js:17)
    at t.conv2d (tf-core.esm.js:17)
    at jt.runKernel.x (tf-core.esm.js:17)
    at tf-core.esm.js:17

我的 Javascript 代码:

let classifier;

let img;

function modelReady(){
  console.log("Model Ready")
  try {
    classifier.predict(img, gotResult);
  } catch (error) {
    console.log("Model Error")
    console.error(error)
  }
}

function preload() {
  img = loadImage('./henry.jpg')
  classifier = ml5.imageClassifier('MobileNet', modelReady);
}

function setup() {
  createCanvas(400, 400);
  background(0)
  image(img, 0, 0);
}

// A function to run when we get any errors and the results
function gotResult(error, results) {
  // Display error in the console
  if (error) {
   console.error(error);
  }
  // The results are in an array ordered by confidence.
  console.log(results);
  console.log('Label: ' + results[0].label);
  console.log('Confidence: ' + nf(results[0].confidence, 0, 2));
}

4

0 回答 0