TensorFlow.js 前端检测用户上传了什么图片并打标签

直接搬官方示例:

<!DOCTYPE>

<html>



<head>

  <link rel="icon" href="data:,">



</head>



<body>

  <!-- Load TensorFlow.js. This is required to use MobileNet. -->

  <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"> </script>

  <!-- Load the MobileNet model. -->

  <script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/mobilenet"> </script>



  <!-- Replace this with your image. Make sure CORS settings allow reading the image! -->

  <img id="img" src="cat.jpg"></img>



  <!-- Place your code in the script tag below. You can also use an external .js file -->

  <script>

    // Notice there is no 'import' statement. 'mobilenet' and 'tf' is

    // available on the index-page because of the script tag above.



    const img = document.getElementById('img');



    // Load the model.

    mobilenet.load().then(model => {

      // Classify the image.

      model.classify(img).then(predictions => {

        console.log('Predictions: ');

        console.log(predictions);

      });

    });

  </script>



</body>



</html>

image.webp

C

精度一般,柴犬会被识别成柯基。

image.webp

C
C
引用
精度一般,柴犬会被识别成柯基。
C 精度一般,柴犬会被识别成柯基。

是狗就行了呗,要求别那么高。

这个模型权重加载时间会很长

v6666
引用
这个模型权重加载时间会很长
v6666 这个模型权重加载时间会很长

没事,边上传边加载,就是给用户个标签建议

C
1