forked from tensorflow/tfjs-models
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
33 lines (27 loc) · 847 Bytes
/
index.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
<!-- 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>