chore(board): python_pyodide下 Teachable Machine 添加模型文件
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
7096
boards/default_src/python_pyodide/origin/teachableModel/model.json
Normal file
7096
boards/default_src/python_pyodide/origin/teachableModel/model.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,10 @@
|
||||
// import * as mobilenet from "@tensorflow-models/mobilenet";
|
||||
import * as tf from '@tensorflow/tfjs';
|
||||
import * as tfvis from '@tensorflow/tfjs-vis';
|
||||
import * as path from 'path';
|
||||
import { inject, ref } from 'vue';
|
||||
import { ElMessage, ElButton, ElCard, ElRow, ElCol, ElInput, ElProgress, ElUpload } from 'element-plus';
|
||||
import { Env } from 'mixly';
|
||||
|
||||
// import 'element-plus/theme-chalk/el-message.css';
|
||||
// import 'element-plus/theme-chalk/el-button.css';
|
||||
@@ -47,7 +49,7 @@ async function train() {
|
||||
showVisPanel.value = true
|
||||
console.log('正在加载Mobilenet……')
|
||||
// net = await mobilenet.load();
|
||||
featureExtractor = await tf.loadGraphModel('/teachableModel/model.json')
|
||||
featureExtractor = await tf.loadGraphModel(path.join(Env.boardDirPath, 'teachableModel/model.json'))
|
||||
|
||||
console.log('Mobilenet加载完成。')
|
||||
if (visPanel)
|
||||
@@ -200,14 +202,14 @@ setInterval(async () => {
|
||||
let activation = featureExtractor.predict(normalized)
|
||||
const pred = model.predict(activation)
|
||||
const predArr = await pred.data()
|
||||
console.log(predArr)
|
||||
// console.log(predArr)
|
||||
classList.value = [
|
||||
...classList.value.map((item, idx) => ({
|
||||
...item,
|
||||
progress: Number((predArr[idx] * 100).toFixed(2)),
|
||||
})),
|
||||
]
|
||||
console.log(classList.value)
|
||||
// console.log(classList.value)
|
||||
imgTensor.dispose()
|
||||
activation.dispose()
|
||||
pred.dispose()
|
||||
@@ -464,10 +466,6 @@ async function saveModel() {
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
.progress {
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
.model-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user