-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
662 lines (578 loc) · 20.2 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
<!doctype html>
<!-- The DOCTYPE declaration above will set the -->
<!-- browser's rendering engine into -->
<!-- "Standards Mode". Replacing this declaration -->
<!-- with a "Quirks Mode" doctype is not supported. -->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Activity Tracker Neural Network Gesture Recognition Tutorial</title>
<link type="text/css" rel="stylesheet" href="css/web-bluetooth.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- library for realtime streaming data visualization -->
<script type="text/javascript" src="js/smoothie.js"></script>
<!-- library for neural network -->
<script type="text/javascript" src="js/synaptic.js"></script>
<!-- Web Bluetooth connection -->
<script>
var button = document.getElementById("connect");
var message = document.getElementById("message");
</script>
<!-- primary app code get web bluetooth data, collect data from model, apply to neural network -->
<script type="text/javascript" src="js/main.js"></script>
<style>
@import url(https://fonts.googleapis.com/css?family=Noto+Sans);
* {
font-family: 'Noto Sans', Arial;
}
body{
background-color: black;
}
#interface-controls{
width: 38%;
margin-top: 5px;
display:inline-block;
}
#btnOne{
z-index: 99;
margin-top: 60px;
}
.range-slider {
z-index: 99;
margin: 18px 0 0 0;
}
.range-slider {
width: 100%;
}
.sample-size-div{
width: 260px;
display: inline-block;
margin-top: 0px;
}
.sample-size-div .range-slider__value{
width: 18px;
}
.sample-size-div p.range-label{
text-align: center;
}
.range-slider__value.master-pose{
background-color: gray;
}
.range-slider p{
margin: 0px;
margin-bottom: -8px;
}
p.range-label{
color: white;
margin-bottom: -10px;
font-size: 11px;
}
.range-slider__range {
-webkit-appearance: none;
width: calc(100% - (65px));
height: 5px;
border-radius: 5px;
background: #d7dcdf;
outline: none;
padding: 0;
margin: 0;
}
.range-slider__range.nn-architecture {
width: calc(100% - (110px));
}
.range-slider__range::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
/* width: 20px;
height: 20px; */
width: 15px;
height: 15px;
border-radius: 50%;
/* background: #2c3e50; */
background: #dbca60;
cursor: pointer;
-webkit-transition: background .15s ease-in-out;
transition: background .15s ease-in-out;
}
.range-slider__range.transform { /* these sliders no longer important so make smaller */
height: 5px;
}
.range-slider__range.transform::-webkit-slider-thumb { /* these sliders no longer important so make smaller */
width: 15px;
height: 15px;
}
.range-slider__range::-webkit-slider-thumb:hover {
background: #1abc9c;
}
.range-slider__range:active::-webkit-slider-thumb {
background: #1abc9c;
}
.range-slider__range::-moz-range-thumb {
width: 20px;
height: 20px;
border: 0;
border-radius: 50%;
background: #2c3e50;
cursor: pointer;
-webkit-transition: background .15s ease-in-out;
transition: background .15s ease-in-out;
}
.range-slider__range::-moz-range-thumb:hover {
background: #1abc9c;
}
.range-slider__range:active::-moz-range-thumb {
background: #1abc9c;
}
.range-slider__value {
display: inline-block;
position: relative;
font-size: 14px;
color: #fff;
line-height: 20px;
text-align: center;
border-radius: 3px;
background: #d2691e;
padding: 5px 12px;
margin-left: 8px;
}
.range-slider__value:after {
position: absolute;
top: 8px;
left: -7px;
width: 0;
height: 0;
border-top: 7px solid transparent;
border-right: 7px solid #d9b32a;
border-bottom: 7px solid transparent;
content: '';
}
::-moz-range-track {
background: #d7dcdf;
border: 0;
}
input::-moz-focus-inner,
input::-moz-focus-outer {
border: 0;
}
.range-slider label {
position: absolute;
width: 20px;
margin-left: 5px;
margin-right: 5px;
text-align: center;
margin-top: 0px;
color: white;
font-size: 12px;
}
.sensor-data .data{
color: white;
width: 15%;
max-width: 150px;
display: inline-block;
overflow: hidden;
font-size: 12px;
}
.sensor-container{
margin-top: 5px;
}
.btn {
padding: 0px;
display: inline-block;
padding: 4px 8px;
margin-bottom: 0;
font-size: 14px;
font-weight: 500;
line-height: 1.3;
text-align: center;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
border: 1px solid transparent;
border-radius: 4px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
.collect.btn , #connect.btn, #train-btn.btn, #activate-btn, #export-btn, #train2-btn.btn, #activate2-btn, #export2-btn{
color: #fff;
background-color: #3bafda;
border-color: #3bafda;
margin-right: 10px;
margin-bottom: 10px;
margin-top: 6px;
width: 180px;
}
#activate-btn, #export-btn, #activate2-btn, #export2-btn{
background-color: #6d6d6d;
border-color: #6d6d6d;
width: 125px;
}
#activate-btn.haveNN, #export-btn.haveNN, #activate2-btn.haveNN, #export2-btn.haveNN{
background-color: green;
border-color: green;
}
#activate-btn.activeNN, #activate2-btn.activeNN, #load-nn-btn.activeNN, #load-nn-btn.activatedNN{
background-color: red;
border-color: red;
}
#load-nn-btn.btn, #load-btn.btn, #print-btn.btn{
width: 112px;
}
.console{
padding-top: 15px;
padding-bottom: 15px;
}
.console div, .console p{
display: inline-block;
margin-top:0px; margin-bottom: 0px;
font-size: 12px;
color:white;
}
.console p span{
color: yellow;
}
div.gamepad-val-display{
width:32%;
display: inline-block;
margin-top:0px; margin-bottom: 0px;
font-size: 12px;
color:white;
}
div.gamepad-val-display span{
color: yellow;
}
#basic-interface-container{
width: 500px;
display: inline-block;
}
.intro{
margin-left: 0px;
margin-bottom: 0px;
width: 500px;
}
#nn-interface-container{
width: 500px;
display: inline-block;
}
.circle-button {
position: absolute;
top: 1.5em;
right: 1.5em;
width: 40px;
height: 40px;
font-size: 1.5em;
color: #fff;
background: #fff;
border: none;
border-radius: 50%;
-webkit-box-shadow: 0 3px 6px rgba(200, 200, 200, 0.275);
box-shadow: 0 3px 6px rgba(200, 200, 200, 0.275);
outline: none;
cursor: pointer;
-webkit-transition: all 300ms ease;
transition: all 300ms ease;
}
.circle-button .close {
-webkit-transition: -webkit-transform 400ms ease;
transition: -webkit-transform 400ms ease;
transition: transform 400ms ease;
transition: transform 400ms ease, -webkit-transform 400ms ease;
}
.circle-button:hover {
-webkit-box-shadow: 0 6px 12px rgba(200, 200, 200, 0.975);
box-shadow: 0 6px 12px rgba(200, 200, 200, 0.975);
}
.closeRotate {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
#data-message{
width: 100%;
display: block;
color: white;
font-size: 0.95em;
}
#data-message div{
display: inline-block;
margin-right: 15px;
}
.data-message-value{
color: yellow;
}
.message-nn1-score, .message-nn2-score{
font-size: 1.4em;
font-weight: 600;
}
.message-nn1-score{
color: rgb(72, 244, 68);
}
.message-nn2-score{
color: rgb(244, 66, 66);
}
.collect.btn{
width: 200px;
margin-left: 0px;
margin-right: 6px;
}
.collect.btn.true{
background-color: #00cc66;
border-color: #00cc66;
}
.collect.btn.false{
background-color: #ff6666;
border-color: #ff6666;
}
.clear.btn{
background-color: #8600b3;
color: white;
padding: 4px 7px;
}
.btn.clear.true{
margin-right: 5px;
}
#nn-slide-controls{
width: 100%;
margin-top: 10px;
}
.nn-architecture-div{
display: inline-block;
width: 45%;
padding-right: 15px;
padding-left: 5px;
margin-bottom: 10px;
position: relative;
margin-top: 5px;
}
.range-slider.nn-architecture p.range-label{
margin-bottom: -5px;
font-size: 16px;
}
.range-slider.nn-architecture label {
margin-top: 25px;
font-size: 14px;
}
input[type="range" i] {
}
input[type="text"]:-ms-input-placeholder {
color: #aaa;
font-weight: 300;
}
.g {
opacity: 1;
}
.clean-slide {
display: inline-block;
width: 100px;
padding: 5px 0 5px 25px;
margin-left: 40px;
font-family: "Open Sans", sans;
font-weight: 400;
font-size: 16px;
color: #377D6A;
background: #efefef;
border: 0;
border-radius: 5px;
outline: 0;
transition: all .3s ease-in-out;
}
#rate-input{
padding-left: 20px;
width: 35px;
}
#iterations-input{
padding-left: 65px;
width: 38px;
}
#error-input{
padding-left: 30px;
width: 35px;
}
#error-input{
padding-left: 30px;
width: 35px;
}
#file-name-input{
padding-left: 50px;
width: 90px;
}
.clean-slide + label {
display: inline-block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
padding: 5px 10px;
font-size: 14px;
line-height: 17px;
text-shadow: 0 1px 0 rgba(19, 74, 70, 0.4);
background: #3bafda;
color: white;
transition: all .3s ease-in-out;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}
.clean-slide:focus,
.clean-slide:active {
color: #377D6A;
background: #fff;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.clean-slide:focus + label,
.clean-slide:active + label {
transform: translateX(-10%);
}
span.text-input-span {
position: relative;
display: inline-block;
margin-right: 6px;
}
body .btn:hover, button.btn:hover {
border-color: white !important;
border: 1px solid !important;
}
.accelerometer-x-key{ background-color: rgb(185, 156, 107); }
.accelerometer-y-key{ background-color: rgb(143, 59, 27); }
.accelerometer-z-key{ background-color: rgb(213, 117, 0); }
.pitch-key{ background-color: rgb(128, 128, 128); }
.roll-key{ background-color: rgb(240, 240, 240); }
.photosensor-key{ background-color: rgb(206, 66, 244); }
.nn1-score-label{ color: rgb(72, 244, 68); font-weight: 600; }
.nn2-score-label{ color: rgb(244, 66, 66); font-weight: 600; }
#dump-print{
background: white;
font-size: 12px;
margin: 30px;
border-radius: 5px;
}
</style>
</head>
<body>
<!-- DISPLAY WEB BLUETOOTH DATA -->
<div class="sensor-container">
<!-- display raw numerical data -->
<div class="sensor-data">
<div class="data"><span class="photosensor-key key"> </span>HR Photosensor: <span class="photosensor-data"></span></div>
<div class="data"><span class="pitch-key key"> </span>Pitch: <span class="accelerometer-pitch-data"></span></div>
<div class="data"><span class="roll-key key"> </span>Roll: <span class="accelerometer-roll-data"></span></div>
<div class="data"><span class="accelerometer-x-key key"> </span>Accelerometer X: <span class="accelerometer-x-data"></span></div>
<div class="data"><span class="accelerometer-y-key key"> </span>Accelerometer Y: <span class="accelerometer-y-data"></span></div>
<div class="data"><span class="accelerometer-z-key key"> </span>Accelerometer Z: <span class="accelerometer-z-data"></span></div>
</div>
<!-- container for smoothie.js timeseries streaming data chart (canvas) -->
<div id="streaming-data-chart" class="smoothie-container"></div>
<!-- min/max streaming data chart -->
<div class="circle-button" id="circleDrop"><img id="chart-size-button" class="close" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/324479/close.svg" /></div>
</div>
<div id="data-message">
<div>NN1 TRUE: <span class="message-nn1-true data-message-value">0</span></div>
<div>NN1 FALSE: <span class="message-nn1-false data-message-value">0</span></div>
<div>NN2 TRUE: <span class="message-nn2-true data-message-value">0</span></div>
<div>NN2 FALSE: <span class="message-nn2-false data-message-value">0</span></div>
<div>Neural Network 1 <span class="nn1-score-label">SCORE</span>: <span class="message-nn1-score data-message-value">na</span></div>
<div>Neural Network 2 <span class="nn2-score-label">SCORE</span>: <span class="message-nn2-score data-message-value">na</span></div>
</div>
<div id="basic-interface-container">
<div class="intro">
<button id="connect" class="btn">
Connect
</button>
<span id="message"></span>
<div class="range-slider sample-size-div">
<p class="range-label"># Samples</p>
<input class="range-slider__range sample-size" type="range" value="25" min="25" max="500" step="25">
<span class="range-slider__value">0</span>
</div>
<button id="collect-true-1" class="btn collect true collect-true-1">Neural Network 1 Add True</button>
<button id="collect-false-1" class="btn collect false collect-false-1">Neural Network 1 Add False</button>
<button id="clear-true-1" class="btn clear true clear-1">clear</button>
<button id="collect-true-2" class="btn collect true collect-true-2">Neural Network 2 Add True</button>
<button id="collect-false-2" class="btn collect false collect-false-2">Neural Network 2 Add False</button>
<button id="clear-true-2" class="btn clear true clear-2">clear</button>
</div>
<div id="nn-interface-container" class="data-ui">
<button id="train-btn" class="btn">Train Neural Network 1</button>
<button id="export-btn" class="btn">Export NN1</button>
<button id="activate-btn" class="btn">Activate NN1</button>
<button id="train2-btn" class="btn">Train Neural Network 2</button>
<button id="export2-btn" class="btn">Export NN2</button>
<button id="activate2-btn" class="btn">Activate NN2</button>
</div>
</div>
<div id="nn-slide-controls">
<span class="text-input-span">
<input class="clean-slide g" id="rate-input" type="text" value="0.06" placeholder=""><label for="rate">Rate</label>
</span>
<span class="text-input-span">
<input class="clean-slide g" id="iterations-input" type="text" value="1500" placeholder=""><label for="iterations">Iterations</label>
</span>
<span class="text-input-span">
<input class="clean-slide g" id="error-input" type="text" value="0.06" placeholder=""><label for="error">Error</label>
</span>
<div class="range-slider nn-architecture-div nn-architecture">
<p class="range-label">Select Neural Network Architecture (LSTM Multilayer Perceptron)</p>
<input class="range-slider__range nn-architecture" type="range" value="4" min="0" max="5" step="1" increment="1">
<span class="range-slider__value nn-architecture">3:3:3:1</span>
</div>
</div>
<div id="dump-print"></div>
</body>
<!-- Web Bluetooth connection -->
<script>
//var button = document.getElementById("connect");
//var message = document.getElementById("message");
/*
$( document ).ready(function() {
console.log( "ready!" );
var rangeSlider = function(){
var slider = $('.range-slider'),
range = $('.range-slider__range'),
value = $('.range-slider__value');
slider.each(function(){
value.each(function(){
var value = $(this).prev().attr('value');
$(this).html(value);
});
if( $(this).hasClass('nn-architecture') ){ $('.range-slider__value.nn-architecture').html('7:5:2:1'); }
range.on('input', function(){
var labels = ['5:2:1', '5:5:1', '5:5:2:1', '5:5:5:1', '7:7:1', '7:5:2:1', '7:7:2:1', '7:7:7:1', '2:2:2:1'];
$(this).next(value).html(this.value);
if( $(this).hasClass('nn-architecture') ){ $(this).next(value).html( labels[this.value] ); }
});
});
}
rangeSlider();
//RANGE SLIDER EVENT HANDLER
$( ".range-slider" ).each(function() {
if($(this).hasClass("nn-architecture")){
// Add labels to slider whose values
// are specified by min, max and whose
// step is set to 1
// Get the options for this slider
//var opt = $(this).data().uiSlider.options;
// Get the number of possible values
var $input = $(this).find("input");
var min = parseInt($input.attr("min"));
var max = parseInt($input.attr("max"));
var step = parseInt($input.attr("step"));
var increment = parseInt($input.attr("increment"));
var vals = max - min; //opt.max - opt.min;
//if(min < 0){ vals = max + min; }
var labels = ['5:2:1', '5:5:1', '5:5:2:1', '5:5:5:1', '7:7:1', '7:5:2:1', '7:7:2:1', '7:7:7:1', '2:2:2:1'];
// Space out values
for (var i = 0; (i * increment) <= vals; i++) {
var s = min + (i * increment);
var el = $('<label>'+ labels[s] +'</label>').css('left',( 4 + Math.abs((s-min)/vals) *($input.width() -24)+'px'));
// var el = $('<label>'+ s +'</label>').css('left',( 3 + ((s-min)/vals) *($input.width() -24)+'px'));
if(s == 0){ el = $('<label>'+ labels[s] +'</label>').css('left',( 21 + Math.abs((s-min)/vals) *($input.width() -24)+'px')); }
if(s == vals){ el = $('<label>'+ labels[s] +'</label>').css('left',( -20 + Math.abs((s-min)/vals) *($input.width() -24)+'px')); }
$(this).append(el);
}
}
});
}); //end of on document load
*/
</script>
</html>