chore(board): python_pyodide下 Teachable Machine 添加模型文件

This commit is contained in:
王立帮
2025-09-22 12:34:04 +08:00
parent 67996ae4f3
commit 1495690efe
5 changed files with 7101 additions and 7 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -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;