-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
137 lines (132 loc) · 6.92 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>tf-js-classification-app</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!-- Load the latest version of TensorFlow.js -->
<script src="https://unpkg.com/@tensorflow/tfjs"></script>
<script src="https://unpkg.com/@tensorflow-models/mobilenet"></script>
<script src="https://unpkg.com/@tensorflow-models/knn-classifier"></script>
</head>
<body style="background-color: #545454;">
<section style="background-color: #545454;height: 100vh;width: 100%;color: rgb(67,70,74);">
<header style="height: 10vh;background-color: #1e1e1e;">
<h1 class="text-center" style="color: rgb(203,206,210);font-size: 26px;padding: 2vh;">Tensorflow.js
Classifier</h1>
<section
class="d-flex d-xl-flex flex-column justify-content-center align-items-center justify-content-xl-center"
style="width: 100%;height: 45vh;">
<!-- Add an video which is the webcam -->
<video autoplay playsinline muted id="webcam" style="height: 40vh; max-width: 100%" width="560"
height="315"></video>
</section>
<!-- Add checkbox for custom classifier -->
<div class="d-flex flex-row justify-content-center align-items-center"
style="color:rgb(212,212,213); padding-top:20px; width: 100%"><p>Check for custom classifier:</p>
<div style="padding-left:10px; padding-bottom: 17px"><input type="checkbox" id="myCheck"></div>
</div>
<!-- If checkbox not checked show prediction of mobileNet -->
<div class="d-flex flex-row justify-content-center align-items-center"
style="color:rgb(212,212,213); padding-top:20px; width: 100%">
<p id="prediction"></p>
</div>
<!-- Buttons and table for custom classifier, visible if checkbox checked -->
<section id="custom" class="d-flex flex-column justify-content-between align-items-center"
style="height: 50vh;width: 100%; min-height: 300px; visibility: hidden">
<!-- Add Buttons -->
<div class="btn-group btn-group-sm d-xl-flex justify-content-xl-center" role="group">
<button class="btn btn-dark text-center" style="margin: 2px;width: 100px;" type="button" id="class-a">
Class A
</button>
<button class="btn btn-dark text-center" style="margin: 2px;width: 100px;" type="button" id="class-b">
Class B
</button>
<button class="btn btn-dark text-center" style="margin: 2px;width: 100px;" type="button" id="class-c">
Class C
</button>
<button class="btn btn-dark text-center" style="margin: 2px;width: 100px;" type="button" id="class-d">
Class D
</button>
</div>
<!-- Add table -->
<div id="table" class="table-responsive text-center"
style="padding: 0px; width: 50%;padding-top: 20px; min-width: 300px">
<table class="table">
<thead class="text-monospace border-dark">
<tr>
<th style="color: rgb(212,212,213);">Class</th>
<th style="color: rgb(212,212,213);">Prediction</th>
<th style="color: rgb(212,212,213);">Input number</th>
<th style="color: rgb(212,212,213);">Last Image</th>
</tr>
</thead>
<tbody>
<tr id="tab-A">
<td style="color: rgb(212,212,213);font-style: normal;">A</td>
<td style="color: rgb(212,212,213);">
<div id="out-A"></div>
</td>
<td style="color: rgb(212,212,213);">
<div id="num-a"></div>
</td>
<td style="color: rgb(212,212,213);">
<canvas id="canvas-a" width="50" height="32"></canvas>
</td>
</tr>
<tr id="tab-B">
<td style="color: rgb(212,212,213);">B</td>
<td style="color: rgb(212,212,213);">
<div id="out-B"></div>
</td>
<td style="color: rgb(212,212,213);">
<div id="num-b"></div>
</td>
<td style="color: rgb(212,212,213);">
<canvas id="canvas-b" width="50" height="32"></canvas>
</td>
</tr>
<tr id="tab-C">
<td style="color: rgb(212,212,213);">C</td>
<td style="color: rgb(212,212,213);">
<div id="out-C"></div>
</td>
<td style="color: rgb(212,212,213);">
<div id="num-c"></div>
</td>
<td style="color: rgb(212,212,213);">
<canvas id="canvas-c" width="50" height="32"></canvas>
</td>
</tr>
<tr id="tab-D">
<td style="color: rgb(212,212,213);">D</td>
<td style="color: rgb(212,212,213);">
<div id="out-D"></div>
</td>
<td style="color: rgb(212,212,213);">
<div id="num-d"></div>
</td>
<td style="color: rgb(212,212,213);">
<canvas id="canvas-d" width="50" height="32"></canvas>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</header>
</section>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
<script src="index.js"></script>
</body>
</html>