Python 仅显示图像的AutoMl边缘模型

Python 仅显示图像的AutoMl边缘模型,python,tensorflow,machine-learning,google-cloud-platform,automl,Python,Tensorflow,Machine Learning,Google Cloud Platform,Automl,因此,我是ml新手,在automl上工作,它在线显示预测效果要好得多,但问题是我需要一个离线解决方案,所以我在边缘Tensorflow上部署模型,一旦我训练了模型并将其离线下载。我得到了一个标签txt文件,3个bin文件和1个JSON文件格式的模型文件 我确实读过这篇文章,但我似乎仍然无法让我的模型工作,因为这个链接显示我们必须制作index.html文件我确实复制粘贴了相同的代码并制作了一个html文件,但我不想从google存储中加载图像,所以我给出了与index.html文件在同一文件夹中

因此,我是ml新手,在automl上工作,它在线显示预测效果要好得多,但问题是我需要一个离线解决方案,所以我在边缘Tensorflow上部署模型,一旦我训练了模型并将其离线下载。我得到了一个标签txt文件,3个bin文件和1个JSON文件格式的模型文件

我确实读过这篇文章,但我似乎仍然无法让我的模型工作,因为这个链接显示我们必须制作index.html文件我确实复制粘贴了相同的代码并制作了一个html文件,但我不想从google存储中加载图像,所以我给出了与index.html文件在同一文件夹中的图像路径,并删除了交叉源,但仍然,它只是显示图像,而不是检测图像的概率或诸如此类的东西,是的,我用python打开了Http.server8080,所以没有问题

<script src="https://unpkg.com/@tensorflow/tfjs"></script>
<script src="https://unpkg.com/@tensorflow/tfjs-automl"></script>
<img id="detect" src="1.png">

<script>

async function run() {
const model = await tf.automl.loadImageClassification('model.json');
  const image = document.getElementById('detect');
  const predictions = await model.classify(image);
  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>

异步函数run(){
const model=await tf.automl.loadImageClassification('model.json');
const image=document.getElementById('detect');
常数预测=等待模型。分类(图像);
控制台日志(预测);
//在页面上显示结果对象。
const pre=document.createElement('pre');
pre.textContent=JSON.stringify(预测,null,2);
文件.正文.附加(预);
}
run();

有人能帮我做些什么吗?我已经搜索了许多互联网论坛,但找不到答案。我可以在官方文件之后在本地查看预测。 JS代码或文件上的配置可能会丢失。 我想我修改了一些文件,但我不记得是哪一个,所以我会在我的工作版本中列出所有相关的代码,这样你就可以比较了。 浏览器和Javascript控制台也值得检查(查看>开发者>Chrome中的Javascript控制台)。我的quickstart Tensorflow.js工作预测正在Chrome上运行

dict.txt

sunflowers
tulips
dandelion
roses
daisy
image.jpeg
binaryfile.bin
index.html

<head>
</head>
<body>
    <script src="https://unpkg.com/@tensorflow/tfjs"></script>
    <script src="https://unpkg.com/@tensorflow/tfjs-automl"></script>
    <img id="daisy" crossorigin="anonymous" src="./download.jpeg">
    <script>
    async function run() {
        const model = await tf.automl.loadImageClassification('model.json');
        const image = document.getElementById('daisy');
        const predictions = await model.classify(image);
        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>

异步函数run(){
const model=await tf.automl.loadImageClassification('model.json');
const image=document.getElementById('daisy');
常数预测=等待模型。分类(图像);
控制台日志(预测);
//在页面上显示结果对象。
const pre=document.createElement('pre');
pre.textContent=JSON.stringify(预测,null,2);
文件.正文.附加(预);
}
run();
请注意,我将脚本标记放在正文中,因为您希望预测显示在页面内容中,就像在教程中一样

model.json