【问题标题】:AutoMl Edge Model Showing Only ImageAutoMl 边缘模型仅显示图像
【发布时间】:2020-01-24 20:55:05
【问题描述】:

所以我是 ml 的新手,并且正在研究 automl,它在线显示预测要好得多,但问题是我需要一个离线解决方案,所以我在训练模型并下载后将模型部署在边缘 Tensorflow 上离线。我有一个标签 txt 文件、3 个 bin 文件和 1 个 JSON 文件格式的模型文件。

我确实读过这个Google Edge Vision,但我似乎仍然无法让我的模型工作,因为这个链接显示我们必须制作一个 index.html 文件我复制粘贴了相同的代码并制作了一个 Html 文件,但是我不想从谷歌存储加载图像,所以我给出了与 index.html 文件在同一文件夹中的图像路径并删除了跨域,但它仍然只是显示图像而不是检测到的概率图片或类似的东西,是的,我确实用python打开了Http.server 8080,所以没问题

<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>

谁能帮我看看我应该怎么做我已经搜索了很多互联网论坛但找不到答案

【问题讨论】:

    标签: python tensorflow machine-learning google-cloud-platform automl


    【解决方案1】:

    我可以按照官方文档在本地检查预测。 JS 代码或 on 文件可能存在一些错误配置。 我想我修改了一些文件,但我不记得是哪一个,所以我将列出我最终在我的工作版本上得到的所有相关代码,以便您进行比较。 浏览器和 Javascript 控制台也值得检查(Chrome 中的查看 > 开发人员 > JavaScript 控制台)。我的工作快速入门 Tensorflow.js 工作预测正在 Chrome 上运行。

    dict.txt

    sunflowers
    tulips
    dandelion
    roses
    daisy
    

    image.jpeg
    二进制文件.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>
    

    请注意,我将脚本标签放在正文中,因为您希望预测显示在页面内容中,就像教程中一样。

    model.json

    【讨论】:

      猜你喜欢
      • 2016-10-07
      • 1970-01-01
      • 2013-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-24
      • 2020-09-10
      相关资源
      最近更新 更多