-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
657 lines (591 loc) · 22.1 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href = "https://fonts.googleapis.com/css2? family = Noto + Sans + KR : wght @ 100 & display = swap"rel = "stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Do+Hyeon&display=swap" rel="stylesheet">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<style media="screen">
body {
background:#34495e;
}
*{
font-family : 'Do Hyeon', sans-serif;
list-style: none;
text-decoration: none;
border-collapse: collapse;
margin: 0px;
padding: 0px;
color: #000;
}
img{display:block;vertical-align: center}
.intro_bg{
background-image: url("image/intro.png");
width: 100%;
height: 718px;
}
.header{
display: flex;
width: 1280;
margin:auto;
height: 86px;
}
.searchArea{
width: 300px;
height: 40px;
background: rgba(0, 0, 0, 0.5);
border-radius: 5px;
margin-top: 24px;
}
.searchArea > form > input{
border:none;
width: 250px;
height:40px;
background: rgba(0, 0, 0, 0.0);
color:#fff;
padding-left:10px;
}
.searchArea > form > span{
width: 50px;
color:#fff;
font-weight:bold;
cursor: pointer;
}
.nav{
display: flex;
justify-content: flex-end;
line-height: 86px;
width: calc(1280px - 300px);
color:#fff;
}
.nav>li{
margin-left: 84px;
}
.nav>li>a{
color:#fff;
}
* {
box-sizing: border-box;
}
.header h1 {
font-weight: 300;
display: inline;
}
h2 {
color: #89867e;
text-align: center;
font-weight: 300;
}
.color {
width: 350px;
margin: 0 auto;
}
.color li {
margin: 0 15px 0 0;
width: 30px;
height: 30px;
display: inline-block;
border-radius: 100%;
}
.color .red {background: #fa5a5a;}
.color .yellow {background: #f0d264;}
.color .green {background: #82c8a0;}
.color .cyan {background: #7fccde;}
.color .blue {background: #6698cb;}
.color .purple {background: #cb99c5;}
.content,
.content-gradient,
.content-3d {
margin: 40px auto;
}
.content {
width: 80%;
max-width: 700px;
}
.content-3d {
width: 50%;
max-width: 300px;
}
pre {
width: 100%;
padding: 30px;
background-color: rgba(0, 0, 0, 0.72);
color: #f8f8f2;
border-radius: 0 0 4px 4px;
margin-top: 20px;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
pre .bt {color: #f8f8f2;} /* <> */
pre .anc {color: #f92672;} /* anchor tag */
pre .att {color: #a6a926;} /* attribute */
pre .val {color: #e6db74;} /* value */
.btn-container, .container {
background-color: white;
border-radius: 4px;
text-align: center;
margin-bottom: 40px;
}
.container h2 {
padding-top: 30px;
font-weight: 300;
}
.btn, .btn-two {
margin: 9px;
}
.btn-gradient {
margin: 5px;
}
a[class*="btn"] {text-decoration: none;}
input[class*="btn"],
button[class*="btn"] {border: 0;}
/* Here you can change the button sizes */
.btn.large,
.btn-two.large,
.btn-effect.large {
padding: 20px 40px;
font-size: 22px;
}
.btn.small,
.btn-two.small,
.btn-gradient.small,
.btn-effect.small {
padding: 8px 18px;
font-size: 14px;
}
.btn.mini,
.btn-two.mini,
.btn-gradient.mini,
.btn-effect.mini {
padding: 4px 12px;
font-size: 12px;
}
.btn.block,
.btn-two.block,
.btn-gradient.block,
.btn-effect.block {
display: block;
width: 60%;
margin-left: auto;
margin-right: auto;
text-align: center;
}
.btn-gradient.large {
padding: 15px 45px;
font-size: 22px;
}
/* Colors for .btn and .btn-two */
.btn.blue, .btn-two.blue {background-color: #7fb1bf;}
.btn.green, .btn-two.green {background-color: #9abf7f;}
.btn.red, .btn-two.red {background-color: #fa5a5a;}
.btn.purple, .btn-two.purple {background-color: #cb99c5;}
.btn.cyan, .btn-two.cyan {background-color: #7fccde;}
.btn.yellow, .btn-two.yellow {background-color: #f0d264;}
.rounded {
border-radius: 10px;
}
/* default button style */
.btn {
position: relative;
border: 0;
padding: 15px 25px;
display: inline-block;
text-align: center;
color: white;
}
.btn:active {
top: 4px;
}
/* color classes for .btn */
.btn.blue {box-shadow: 0px 4px #74a3b0;}
.btn.blue:active {box-shadow: 0 0 #74a3b0; background-color: #709CA8;}
.btn.green {box-shadow: 0px 4px 0px #87a86f;}
.btn.green:active {box-shadow: 0 0 #87a86f; background-color: #87a86f;}
.btn.red {box-shadow:0px 4px 0px #E04342;}
.btn.red:active {box-shadow: 0 0 #ff4c4b; background-color: #ff4c4b;}
.btn.purple {box-shadow:0px 4px 0px #AD83A8;}
.btn.purple:active {box-shadow: 0 0 #BA8CB5; background-color: #BA8CB5;}
.btn.cyan {box-shadow:0px 4px 0px #73B9C9;}
.btn.cyan:active {box-shadow: 0 0 #73B9C9; background-color: #70B4C4;}
.btn.yellow {box-shadow:0px 4px 0px #D1B757;}
.btn.yellow:active {box-shadow: 0 0 #ff4c4b; background-color: #D6BB59;}
/* Button two - I have no creativity for names */
.btn-two {
color: white;
padding: 15px 25px;
display: inline-block;
border: 1px solid rgba(0,0,0,0.21);
border-bottom-color: rgba(0,0,0,0.34);
text-shadow:0 1px 0 rgba(0,0,0,0.15);
box-shadow: 0 1px 0 rgba(255,255,255,0.34) inset,
0 2px 0 -1px rgba(0,0,0,0.13),
0 3px 0 -1px rgba(0,0,0,0.08),
0 3px 13px -1px rgba(0,0,0,0.21);
}
.btn-two:active {
top: 1px;
border-color: rgba(0,0,0,0.34) rgba(0,0,0,0.21) rgba(0,0,0,0.21);
box-shadow: 0 1px 0 rgba(255,255,255,0.89),0 1px rgba(0,0,0,0.05) inset;
position: relative;
}
/* 3D Button */
.btn-3d {
position: relative;
display: inline-block;
font-size: 22px;
padding: 20px 60px;
color: white;
margin: 20px 10px 10px;
border-radius: 6px;
text-align: center;
transition: top .01s linear;
text-shadow: 0 1px 0 rgba(0,0,0,0.15);
}
.btn-3d.red:hover {background-color: #e74c3c;}
.btn-3d.blue:hover {background-color: #699DD1;}
.btn-3d.green:hover {background-color: #80C49D;}
.btn-3d.purple:hover {background-color: #D19ECB;}
.btn-3d.yellow:hover {background-color: #F0D264;}
.btn-3d.cyan:hover {background-color: #82D1E3;}
.btn-3d:active {
top: 9px;
}
/* 3D button colors */
.btn-3d.red {
background-color: #e74c3c;
box-shadow: 0 0 0 1px #c63702 inset,
0 0 0 2px rgba(255,255,255,0.15) inset,
0 8px 0 0 #C24032,
0 8px 0 1px rgba(0,0,0,0.4),
0 8px 8px 1px rgba(0,0,0,0.5);
}
.btn-3d.red:active {
box-shadow: 0 0 0 1px #c63702 inset,
0 0 0 2px rgba(255,255,255,0.15) inset,
0 0 0 1px rgba(0,0,0,0.4);
}
.btn-3d.blue {
background-color: #6DA2D9;
box-shadow: 0 0 0 1px #6698cb inset,
0 0 0 2px rgba(255,255,255,0.15) inset,
0 8px 0 0 rgba(110, 164, 219, .7),
0 8px 0 1px rgba(0,0,0,.4),
0 8px 8px 1px rgba(0,0,0,0.5);
}
.btn-3d.blue:active {
box-shadow: 0 0 0 1px #6191C2 inset,
0 0 0 2px rgba(255,255,255,0.15) inset,
0 0 0 1px rgba(0,0,0,0.4);
}
.btn-3d.green {
background-color: #82c8a0;
box-shadow: 0 0 0 1px #82c8a0 inset,
0 0 0 2px rgba(255,255,255,0.15) inset,
0 8px 0 0 rgba(126, 194, 155, .7),
0 8px 0 1px rgba(0,0,0,.4),
0 8px 8px 1px rgba(0,0,0,0.5);
}
.btn-3d.green:active {
box-shadow: 0 0 0 1px #82c8a0 inset,
0 0 0 2px rgba(255,255,255,0.15) inset,
0 0 0 1px rgba(0,0,0,0.4);
}
.btn-3d.purple {
background-color: #cb99c5;
box-shadow: 0 0 0 1px #cb99c5 inset,
0 0 0 2px rgba(255,255,255,0.15) inset,
0 8px 0 0 rgba(189, 142, 183, .7),
0 8px 0 1px rgba(0,0,0,.4),
0 8px 8px 1px rgba(0,0,0,0.5);
}
.btn-3d.purple:active {
box-shadow: 0 0 0 1px #cb99c5 inset,
0 0 0 2px rgba(255,255,255,0.15) inset,
0 0 0 1px rgba(0,0,0,0.4);
}
.btn-3d.cyan {
background-color: #7fccde;
box-shadow: 0 0 0 1px #7fccde inset,
0 0 0 2px rgba(255,255,255,0.15) inset,
0 8px 0 0 rgba(102, 164, 178, .6),
0 8px 0 1px rgba(0,0,0,.4),
0 8px 8px 1px rgba(0,0,0,0.5);
}
.btn-3d.cyan:active {
box-shadow: 0 0 0 1px #7fccde inset,
0 0 0 2px rgba(255,255,255,0.15) inset,
0 0 0 1px rgba(0,0,0,0.4);
}
.btn-3d.yellow {
background-color: #F0D264;
box-shadow: 0 0 0 1px #F0D264 inset,
0 0 0 2px rgba(255,255,255,0.15) inset,
0 8px 0 0 rgba(196, 172, 83, .7),
0 8px 0 1px rgba(0,0,0,.4),
0 8px 8px 1px rgba(0,0,0,0.5);
}
.btn-3d.yellow:active {
box-shadow: 0 0 0 1px #F0D264 inset,
0 0 0 2px rgba(255,255,255,0.15) inset,
0 0 0 1px rgba(0,0,0,0.4);
}
/* Gradient buttons */
.btn-gradient {
text-decoration: none;
color: white;
padding: 10px 30px;
display: inline-block;
position: relative;
border: 1px solid rgba(0,0,0,0.21);
border-bottom: 4px solid rgba(0,0,0,0.21);
border-radius: 4px;
text-shadow: 0 1px 0 rgba(0,0,0,0.15);
}
.box-container{display: block;margin:auto}
img{display:inherit;margin:auto}
/* Gradient - ugly css is ugly */
.btn-gradient.cyan {
background: rgba(27,188,194,1);
background: -webkit-gradient(linear, 0 0, 0 100%, from(rgba(27,188,194,1)), to(rgba(24,163,168,1)));
background: -webkit-linear-gradient(rgba(27,188,194,1) 0%, rgba(24,163,168,1) 100%);
background: -moz-linear-gradient(rgba(27,188,194,1) 0%, rgba(24,163,168,1) 100%);
background: -o-linear-gradient(rgba(27,188,194,1) 0%, rgba(24,163,168,1) 100%);
background: linear-gradient(rgba(27,188,194,1) 0%, rgba(24,163,168,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#1bbcc2', endColorstr='#18a3a8', GradientType=0);
}
.btn-gradient.red{
display:inline-block;
margin:20px auto;
background: rgba(250,90,90,1);
background: -webkit-gradient(linear, 0 0, 0 100%, from(rgba(250,90,90,1)), to(rgba(232,81,81,1)));
background: -webkit-linear-gradient(rgba(250,90,90,1) 0%, rgba(232,81,81,1) 100%);
background: -moz-linear-gradient(rgba(250,90,90,1) 0%, rgba(232,81,81,1) 100%);
background: -o-linear-gradient(rgba(250,90,90,1) 0%, rgba(232,81,81,1) 100%);
background: linear-gradient(rgba(250,90,90,1) 0%, rgba(232,81,81,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fa5a5a', endColorstr='#e85151', GradientType=0 );
}
.btn-gradient.orange {
background: rgba(255,105,30,1);
background: -webkit-gradient(linear, 0 0, 0 100%, from(rgba(255,105,30,1)), to(rgba(230,95,28,1)));
background: -webkit-linear-gradient(rgba(255,105,30,1) 0%, rgba(230,95,28,1) 100%);
background: -moz-linear-gradient(rgba(255,105,30,1) 0%, rgba(230,95,28,1) 100%);
background: -o-linear-gradient(rgba(255,105,30,1) 0%, rgba(230,95,28,1) 100%);
background: linear-gradient(rgba(255,105,30,1) 0%, rgba(230,95,28,1) 100%);
}
.btn-gradient.blue {
background: rgba(102,152,203,1);
background: -moz-linear-gradient(top, rgba(102,152,203,1) 0%, rgba(92,138,184,1) 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(102,152,203,1)), color-stop(100%, rgba(92,138,184,1)));
background: -webkit-linear-gradient(top, rgba(102,152,203,1) 0%, rgba(92,138,184,1) 100%);
background: -o-linear-gradient(top, rgba(102,152,203,1) 0%, rgba(92,138,184,1) 100%);
background: -ms-linear-gradient(top, rgba(102,152,203,1) 0%, rgba(92,138,184,1) 100%);
background: linear-gradient(to bottom, rgba(102,152,203,1) 0%, rgba(92,138,184,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6698cb', endColorstr='#5c8ab8', GradientType=0 );
}
.btn-gradient.purple {
background: rgba(203,153,197,1);
background: -moz-linear-gradient(top, rgba(203,153,197,1) 0%, rgba(181,134,176,1) 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(203,153,197,1)), color-stop(100%, rgba(181,134,176,1)));
background: -webkit-linear-gradient(top, rgba(203,153,197,1) 0%, rgba(181,134,176,1) 100%);
background: -o-linear-gradient(top, rgba(203,153,197,1) 0%, rgba(181,134,176,1) 100%);
background: -ms-linear-gradient(top, rgba(203,153,197,1) 0%, rgba(181,134,176,1) 100%);
background: linear-gradient(to bottom, rgba(203,153,197,1) 0%, rgba(181,134,176,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cb99c5', endColorstr='#b586b0', GradientType=0 );
}
.btn-gradient.yellow {
background: rgba(240,210,100,1);
background: -webkit-gradient(linear, 0 0, 0 100%, from(rgba(240,210,100,1)), to(rgba(229,201,96,1)));
background: -webkit-linear-gradient(rgba(240,210,100,1) 0%, rgba(229,201,96,1) 100%);
background: -moz-linear-gradient(rgba(240,210,100,1) 0%, rgba(229,201,96,1) 100%);
background: -o-linear-gradient(rgba(240,210,100,1) 0%, rgba(229,201,96,1) 100%);
background: linear-gradient(rgba(240,210,100,1) 0%, rgba(229,201,96,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f0d264', endColorstr='#e5c960', GradientType=0 );
}
.btn-gradient.green {
background: rgba(130,200,160,1);
background: -moz-linear-gradient(top, rgba(130,200,160,1) 0%, rgba(130,199,158,1) 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(130,200,160,1)), color-stop(100%, rgba(130,199,158,1)));
background: -webkit-linear-gradient(top, rgba(130,200,160,1) 0%, rgba(130,199,158,1) 100%);
background: -o-linear-gradient(top, rgba(130,200,160,1) 0%, rgba(130,199,158,1) 100%);
background: -ms-linear-gradient(top, rgba(130,200,160,1) 0%, rgba(130,199,158,1) 100%);
background: linear-gradient(to bottom, rgba(130,200,160,1) 0%, rgba(124, 185, 149, 1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#82c8a0', endColorstr='#82c79e', GradientType=0 );
}
.btn-gradient.red:active {background: #E35252;}
.btn-gradient.orange:active {background: #E8601B;}
.btn-gradient.cyan:active {background: #169499;}
.btn-gradient.blue:active {background: #608FBF;}
.btn-gradient.purple:active {background: #BD8EB7;}
.btn-gradient.yellow:active {background: #DBC05B;}
.btn-gradient.green:active {background: #72B08E;}
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,700|Shrikhand');
.page-title {
margin-bottom: 1.5rem;
margin-top:1.2rem;
font-family: 'Do Hyeon', sans-serif;
font-size: 2.6rem;
line-height: 1.2;
color:white;
text-align:center;
@media (min-width: 450px) {
font-size: 2rem;
}
.page-sub {color:white;}
div{color:white}
canvas {display:flex;justify-content: center; align-items: center;margin:auto;padding-top:20px}
</style>
<title>Lost Pet Finder</title>
</head>
<body>
<input type="button" id="button1" onclick="click1();" value="" />
<script>
function click1() {
let image = document.createElement("img");
image.src = "클릭후사진.png" ;
document.querySelector("div").appendChild(image);
/* 2시간 동안 했는데 포기 ㅜㅜ */
}
</script>
<section class="page-content">
<h1 class="page-title">🐾 Lost pet Finder 🐾</h1>
<p class="page-sub" style="color:white;text-align:center">잃어버린 반려동물을 머신러닝을 통해 찾아드립니다.</p>
</section>
<h2 style="color:white;padding-top:20px">이미지 업로드로 찾아보자</h2>
<div class="cover" style="display:flex;margin:auto">
<button class="btn-gradient red" type="button" onclick="init()">모델 읽어오기</button>
<button class="btn-gradient red" type="button" onclick="predict()">예측</button>
</div>
<input type="file" style="display:block;margin:auto;color:white;padding-bottom:4px" class="" name="" id="inputimg" onchange="preview()">
<div class="box-container">
<img alt="" id="animalimg" style="width: 300px; height: 300px;">
</div>
<div id="webcam-container"></div>
<div id="label-container" style="text-align:center; color:#ffffff"></div>
<img id="말티즈" src="./말티즈주작용.png" style="display: none;"onclick ="click1()"></img>
<img id="포메라니안" src="./포메주작용.png" style="display: none ;"></img>
<!-- <img id="말티즈" src="./주작용.png" style="display: none;"></img>
<img id="말티즈" src="./주작용.png" style="display: none;"></img>
<img id="말티즈" src="./주작용.png" style="display: none;"></img>
<img id="말티즈" src="./주작용.png" style="display: none;"></img>
<img id="말티즈" src="./주작용.png" style="display: none;"></img> -->
<h2 style="color:white;padding-top:20px">실시간 영상으로 찾아보자</h2>
<button class="btn-gradient red" style="display:block;margin:10px auto 0;" type="button" onclick="init2()">녹화 시작</button>
<div class="cover" style="display:flex;margin:auto;padding-top:20px">
<div id="webcam-container2" style="display:flex;margin:auto"></div>
</div>
<div id="label-container2" style="text-align:center; color:#ffffff"></div>
</body>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@teachablemachine/[email protected]/dist/teachablemachine-image.min.js"></script>
<script type="text/javascript">
// More API functions here:
// https://github.com/googlecreativelab/teachablemachine-community/tree/master/libraries/image
//미리보기 이미지 출력하기
function preview() {
var imgfile = document.getElementById("inputimg")
var url = window.URL.createObjectURL(imgfile.files[0])
var imgdom = document.getElementById("animalimg")
imgdom.src = url
}
// the link to your model provided by Teachable Machine export panel
const URL = "https://teachablemachine.withgoogle.com/models/5cUbdVkVI/";
let model, webcam, labelContainer, maxPredictions;
// Load the image model and setup the webcam
async function init() {
const modelURL = URL + "model.json";
const metadataURL = URL + "metadata.json";
// load the model and metadata
// Refer to tmImage.loadFromFiles() in the API to support files from a file picker
// or files from your local hard drive
// Note: the pose library adds "tmImage" object to your window (window.tmImage)
model = await tmImage.load(modelURL, metadataURL);
maxPredictions = model.getTotalClasses()+1;
// Convenience function to setup a webcam
// const flip = true; // whether to flip the webcam
// webcam = new tmImage.Webcam(200, 200, flip); // width, height, flip
// await webcam.setup(); // request access to the webcam
// await webcam.play();
// window.requestAnimationFrame(loop);
// append elements to the DOM
// document.getElementById("webcam-container").appendChild(webcam.canvas);
labelContainer = document.getElementById("label-container");
for (let i = 0; i < maxPredictions; i++) { // and class labels
labelContainer.appendChild(document.createElement("div"));
}
alert("로딩완료")
}
// async function loop() {
// webcam.update(); // update the webcam frame
// await predict();
// window.requestAnimationFrame(loop);
// }
// run the webcam image through the image model
async function predict() {
// predict can take in an image, video or canvas html element
var imgdom = document.getElementById("animalimg")
// const prediction = await model.predict(webcam.canvas);
const prediction = await model.predict(imgdom);
const maxPred = await findMaxPred(prediction);
let dogName = ""
console.log(prediction);
for (let i = 0; i < maxPredictions; i++) {
const classPrediction = prediction[i]["className"];
if (prediction[i].probability.toFixed(2) == maxPred) {
dogName = prediction[i].className
document.getElementById(dogName).style.display = "block"
console.log(dogName);
labelContainer.childNodes[i].innerHTML = "<h1 style='color:white'>"+classPrediction+"</h1>";
}
}
}
function findMaxPred(pred) {
const maxPred = pred.map(function(data) {
return data.probability.toFixed(2)
})
return Math.max.apply(null, maxPred)
}
async function init2() {
const modelURL = URL + "model.json";
const metadataURL = URL + "metadata.json";
// load the model and metadata
// Refer to tmImage.loadFromFiles() in the API to support files from a file picker
// or files from your local hard drive
// Note: the pose library adds "tmImage" object to your window (window.tmImage)
model = await tmImage.load(modelURL, metadataURL);
maxPredictions = model.getTotalClasses()+1;
// Convenience function to setup a webcam
const flip = true; // whether to flip the webcam
webcam = new tmImage.Webcam(200, 200, flip); // width, height, flip
await webcam.setup(); // request access to the webcam
await webcam.play();
window.requestAnimationFrame(loop);
// append elements to the DOM
document.getElementById("webcam-container2").appendChild(webcam.canvas);
camContainer = document.getElementById("label-container2");
for (let i = 0; i < maxPredictions; i++) { // and class labels
camContainer.appendChild(document.createElement("div"));
}
}
async function loop() {
webcam.update(); // update the webcam frame
await predict2();
window.requestAnimationFrame(loop);
}
// run the webcam image through the image model
async function predict2() {
// predict can take in an image, video or canvas html element
const prediction2 = await model.predict(webcam.canvas);
for (let i = 0; i < maxPredictions; i++) {
const classPrediction2 =
prediction2[i].className + ": " + prediction2[i].probability.toFixed(2);
camContainer.childNodes[i].innerHTML = classPrediction2;
}
camContainer.childNodes[i].innerHTML = ""
}
</script>
</html>