Google Cloud AutoML を使用してカスタム オブジェクト検出モデルをトレーニングし、モデルを TensorflowJS パッケージとしてエクスポートしました。ただし、 https://cloud.google.com/vision/automl/object-detection/docs/tensorflow-js-tutorial?hl=en_USにある HTML 展開の例を使用してモデルを実行しようとすると、そうではないようです仕事に。
エクスポートからの tensorflowjs パッケージ (model.json、dict.txt、group1-shard1of3、group1-shard2of3、group1-shard3of3) は、index.html と同じディレクトリにあります。index2.html もあります。index.html では、ここの例と同じ tfjs と tfjs-automl のインポートを使用します。index2.html では、tfjs と tfjs-automl の CDN ソースを使用しています。
私が従った作成 Web アプリの例は次のとおりです。https://github.com/tensorflow/tfjs/blob/master/tfjs-automl/code_snippets/object_detection.html
私のカスタム オブジェクト検出モデルのレポはhttps://github.com/mmmwembe/automl-tensorflowjs.gitで、tensorflowjs モデル パッケージとテスト イメージが含まれています。
私の Index.html ファイルは次のとおりです。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cards AutoML Model - TensorflowJS</title>
</head>
<body>
<script src="https://unpkg.com/@tensorflow/tfjs"></script>
<script src="https://unpkg.com/@tensorflow/tfjs-automl"></script>
<img id="test-image" src="test-images/test-image-01.jpg">
<script>
async function run() {
const model = await tf.automl.loadObjectDetection('model.json');
const img = document.getElementById('test-image');
const options = {score: 0.5, iou: 0.5, topk: 20};
const predictions = await model.detect(img, options);
// [END load_and_run_model]
console.log(predictions);
// Show the resulting object on the page.
const pre = document.createElement('pre');
pre.textContent = JSON.stringify(predictions, null, 2);
document.body.append(pre);
}
run();
</script>
</body>
</html>
ここで何が欠けていますか?...vscode エディターで Live Server を使用する Chrome ブラウザーと、http-server -p 8000 を使用する nodejs でこれを実行しました