码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 利用tensorflow.js在线实现图像要素识别提取


    什么是Tensorflow.js?

    TensorFlow.js是一个开源的基于硬件加速的JavaScript库,用于训练和部署机器学习模型。谷歌推出的第一个基于TensorFlow的前端深度学习框架TensorFlow.js 是一个开源的用于开发机器学习项目的 WebGL-accelerated JavaScript 库。TensorFlow.js 可以为你提供高性能的、易于使用的机器学习构建模块,允许你在浏览器上训练模型,或以推断模式运行预训练的模型。TensorFlow.js 不仅可以提供低级的机器学习构建模块,还可以提供高级的类似 Keras 的 API 来构建神经网络。

    Tensorflow.js的优点:

    1)不用安装驱动器和软件,通过链接即可分享程序

    2)网页应用交互性更强

    3)有访问GPS,Camera,Microphone,Accelerator,Gyroscope等传感器的标准api(主要是指手机端)

    4)安全性,因为数据都是保存在客户端的

    本文使用TensorFlow.js实现任意图片中主要要素的识别提取:

    代码如下:

    index.html

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>Title</title>
    6. <!-- Load TensorFlow.js. This is required to use coco-ssd model. -->
    7. <script src="tfjs.js"></script>
    8. <!-- Load the coco-ssd model. -->
    9. <script src="coco-ssd.js"></script>
    10. </head>
    11. <body>
    12. <!-- Replace this with your image. Make sure CORS settings allow reading the image! -->
    13. <div>
    14. <img id="img" src="57410e4667f97362aa44af920924938c.jpeg"/>
    15. </div>
    16. <div>
    17. <textarea id="result" style="width:500px;min-height: 300px;"></textarea>
    18. </div>
    19. <!-- Place your code in the script tag below. You can also use an external .js file -->
    20. <script>
    21. // Notice there is no 'import' statement. 'cocoSsd' and 'tf' is
    22. // available on the index-page because of the script tag above.
    23. const img = document.getElementById('img');
    24. // Load the model.
    25. cocoSsd.load().then(model => {
    26. // detect objects in the image.
    27. model.detect(img).then(predictions => {
    28. console.log('Predictions: ', predictions);
    29. var resultStr = "";
    30. for (var item of predictions) {
    31. resultStr += "\n检测到:" + item.class + " ,概率:" + item.score + "\n";
    32. resultStr += "区域:" + item.bbox + "\n";
    33. }
    34. document.getElementById('result').value = resultStr;
    35. });
    36. });
    37. </script>
    38. </body>
    39. </html>

    效果:

    在线演示地址利用tensorflow.js实现图像在线要素识别,可识别大部分物体,并输出结果 (mubanmao.top)icon-default.png?t=M7J4http://mubanmao.top/content/preview?id=f949afd8-973c-461a-bfd6-c2365fe207a0

  • 相关阅读:
    MySQL之基础语句
    面向对象的三大特征
    web前端期末大作业——基于html+css+javascript+jquery+bootstrap响应式户外旅游网站
    GLTF和GLB的区别,各自生成方法
    记一次Hbase2.1.x历史数据数据迁移方案
    MySQL学习笔记
    synchronized关键字在同步代码块中的应用(下)
    windows-连接到同一网络的2台电脑共享文件
    Inception V3 闭眼检测
    网络安全-漏洞与木马
  • 原文地址:https://blog.csdn.net/kongzhonghu/article/details/126722489
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号