[ML] Tensorflow.js + Image segmentPerson
2024-09-08 13:48:28
<!DOCTYPE html>
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
<!-- Load TensorFlow.js -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.2"></script>
<!-- Load BodyPix -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/body-pix@2.0"></script>
</head> <body>
<img
id="image"
src="data:image/image.jpg"
/>
<canvas id="canvas"/> <script>
const img = document.getElementById("image"); function loadAndPredict() {
bodyPix.load()
.then((net)=> net.segmentPersonParts(img))
.then(partSegmentation => {
const coloredPartImage = bodyPix.toColoredPartMask(partSegmentation);
const opacity = 0.7;
const flipHorizontal = false;
const maskBlurAmount = 0;
const pixelCellWidth = 10.0;
const canvas = document.getElementById('canvas');
// Draw the pixelated colored part image on top of the original image onto a
// canvas. Each pixel cell's width will be set to 10 px. The pixelated colored
// part image will be drawn semi-transparent, with an opacity of 0.7, allowing
// for the original image to be visible under.
bodyPix.drawPixelatedMask(
canvas, img, coloredPartImage, opacity, maskBlurAmount,
flipHorizontal, pixelCellWidth);
});
}
loadAndPredict();
</script>
</body>
</html>
最新文章
- hive 调优总结
- 基于VC的ACM音频编程接口压缩Wave音频(一)
- C++: DataGridView::DataSource
- Android-Universal-Image-Loader开源项目的简要说明及使用实例
- JQuery,UIbootstrap风格弹出层
- [POJ1236]Network of Schools(并查集+floyd,伪强连通分量)
- [学习笔记] Web设计过程中该做和不该做的
- PYTHON--定期监测服务器端口,并将结果写入MYSQL
- 使用回调接口实现ActiveX控件和它的容器程序的通讯
- cocos2dx 3.0 飞机大战
- leetcode第40题--First Missing Positive
- tomcat 设置jvm 参数
- 软工作业PSP与单元测试训练:java语言判断电子邮箱格式
- CountDownLatch 闭锁、FutureTask、Semaphore信号量、Barrier栅栏
- mongoDB基础使用
- SpringBoot------连接mysql时出现警告:Establishing SSL connection without server&#39;s identity verification is not recommended
- 简单mysql常用命令
- 正确配置 debian squeeze apt 源
- Docker入门与实践之 Dockerfile 语法详解
- 雷林鹏分享:Ruby 数组(Array)
热门文章
- JPA中JpaRepository的使用
- python+selenium实现自动化百度搜索关键词
- Python之路【第二十八篇】:django视图层、模块层
- Visual Studio 2019激活
- 解决clover配置文件conf.plist中nv_disable=1或者nvda_drv=1不生效或者说不能删除的问题
- MNIST机器学习入门(一)
- C# vb .net实现博物馆哑色框架特效滤镜
- FORM表单 onclick()与onsubmit()
- ioremap
- 在Controller中添加事务管理