-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
40 lines (34 loc) · 1.16 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<img id="sample" src="./train/models/keyboard3.jpg">
<canvas id="output"></canvas>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
<script>
const model = tf.loadLayersModel('./train/models/it-seg-js/model.json', false);
function loadImage(imageId) {
img = (document.getElementById(imageId));
return tf.browser.fromPixels(img);
}
async function predict() {
const model = await tf.loadLayersModel('./train/models/it-seg-js/model.json', false);
model.summary();
t = model.predict(
loadImage("sample").reshape([1, 128, 128, 3])
)
// console.log(t.shape)
// t.print();
// const min = t.min();
// const max = t.max();
// normalized = t.sub(min).div(max.sub(min));
tf.browser.toPixels(t.reshape([128, 128, 1]),
document.getElementById("output"));
}
test = predict();
</script>
</body>
</html>