1 Star 1 Fork 0

Stefan / tfjs-models

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
index.html 847 Bytes
一键复制 编辑 原始数据 按行查看 历史
<!-- Load TensorFlow.js. This is required to use MobileNet. -->
<script src="http://unpkg.com/@tensorflow/tfjs"></script>
<!-- Load the MobileNet model. -->
<script src="../dist/mobilenet.js"></script>
<img id="img" src="coffee.jpg"/>
<script>
const img = document.getElementById('img');
const version = 2;
const alpha = 0.5;
async function run() {
// Load the model.
const model = await mobilenet.load({version, alpha});
// Classify the image.
const predictions = await model.classify(img);
console.log('Predictions');
console.log(predictions);
// Get the logits.
const logits = model.infer(img);
console.log('Logits');
logits.print(true);
// Get the embedding.
const embedding = model.infer(img, true);
console.log('Embedding');
embedding.print(true);
}
run();
</script>
1
https://gitee.com/stefantasy/tfjs-models.git
git@gitee.com:stefantasy/tfjs-models.git
stefantasy
tfjs-models
tfjs-models
master

搜索帮助