Skip to content

Commit 2ddebb0

Browse files
committed
🆕 Initial commit
0 parents  commit 2ddebb0

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Tensorflow with MobileNet
2+
3+
- [tfjs](https://github.com/tensorflow/tfjs)
4+
- [MobileNet](https://github.com/tensorflow/tfjs-models/tree/master/mobilenet)

index.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>MobileNet Introduction</title>
6+
<!-- Import tensorflow dependencies -->
7+
<script
8+
src="https://unpkg.com/@tensorflow/tfjs"
9+
type="text/javascript"
10+
></script>
11+
<script
12+
src="https://unpkg.com/@tensorflow-models/mobilenet"
13+
type="text/javascript"
14+
></script>
15+
</head>
16+
<body>
17+
<h1>MobileNet with TensorFlow.js</h1>
18+
<h2 id="message">Detecting image…</h2>
19+
<img
20+
id="image"
21+
crossorigin
22+
src="https://images.unsplash.com/photo-1473496169904-658ba7c44d8a?ixlib=rb-1.2.1&auto=format&fit=crop&w=1950&q=80"
23+
/>
24+
<script>
25+
// Step 1: Load the model
26+
mobilenet.load().then((net) => {
27+
const targetImage = document.getElementById('image');
28+
const targetText = document.getElementById('message');
29+
30+
// Step 2: Classify the image
31+
net.classify(targetImage).then((result) => {
32+
targetText.innerText = `
33+
Detected: ${result[0].className}
34+
Probability: ${result[0].probability}
35+
`;
36+
});
37+
});
38+
</script>
39+
</body>
40+
</html>

0 commit comments

Comments
 (0)