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 mobilenet from "@tensorflow-models/mobilenet";
|
||||||
import * as tf from '@tensorflow/tfjs';
|
import * as tf from '@tensorflow/tfjs';
|
||||||
import * as tfvis from '@tensorflow/tfjs-vis';
|
import * as tfvis from '@tensorflow/tfjs-vis';
|
||||||
|
import * as path from 'path';
|
||||||
import { inject, ref } from 'vue';
|
import { inject, ref } from 'vue';
|
||||||
import { ElMessage, ElButton, ElCard, ElRow, ElCol, ElInput, ElProgress, ElUpload } from 'element-plus';
|
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-message.css';
|
||||||
// import 'element-plus/theme-chalk/el-button.css';
|
// import 'element-plus/theme-chalk/el-button.css';
|
||||||
@@ -47,7 +49,7 @@ async function train() {
|
|||||||
showVisPanel.value = true
|
showVisPanel.value = true
|
||||||
console.log('正在加载Mobilenet……')
|
console.log('正在加载Mobilenet……')
|
||||||
// net = await mobilenet.load();
|
// 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加载完成。')
|
console.log('Mobilenet加载完成。')
|
||||||
if (visPanel)
|
if (visPanel)
|
||||||
@@ -200,14 +202,14 @@ setInterval(async () => {
|
|||||||
let activation = featureExtractor.predict(normalized)
|
let activation = featureExtractor.predict(normalized)
|
||||||
const pred = model.predict(activation)
|
const pred = model.predict(activation)
|
||||||
const predArr = await pred.data()
|
const predArr = await pred.data()
|
||||||
console.log(predArr)
|
// console.log(predArr)
|
||||||
classList.value = [
|
classList.value = [
|
||||||
...classList.value.map((item, idx) => ({
|
...classList.value.map((item, idx) => ({
|
||||||
...item,
|
...item,
|
||||||
progress: Number((predArr[idx] * 100).toFixed(2)),
|
progress: Number((predArr[idx] * 100).toFixed(2)),
|
||||||
})),
|
})),
|
||||||
]
|
]
|
||||||
console.log(classList.value)
|
// console.log(classList.value)
|
||||||
imgTensor.dispose()
|
imgTensor.dispose()
|
||||||
activation.dispose()
|
activation.dispose()
|
||||||
pred.dispose()
|
pred.dispose()
|
||||||
@@ -464,10 +466,6 @@ async function saveModel() {
|
|||||||
height: 10px;
|
height: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress {
|
|
||||||
padding: 0 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.model-item {
|
.model-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
Reference in New Issue
Block a user