-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
424 lines (393 loc) · 21 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
<!DOCTYPE html>
<html>
<head>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<!-- Bootstrap CSS / JS 적용 (영어판) -->
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z"
crossorigin="anonymous"
/>
<script
src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
crossorigin="anonymous"
></script>
<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"
integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV"
crossorigin="anonymous"
></script>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<title>인공지능 동물상 테스트</title>
<link rel="stylesheet" href="style.css" />
<!-- Go to www.addthis.com/dashboard to customize your tools -->
<script
type="text/javascript"
src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5f49ad0f018a20d7"
></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light nav-distance">
<a class="navbar-brand" href="#">동물상 테스트</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">홈 <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">만드느라</a>
</li>
<li class="nav-item dropdown">
<a
class="nav-link dropdown-toggle"
href="#"
id="navbarDropdown"
role="button"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
>
너무
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true"
>힘들었다</a
>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input
class="form-control mr-sm-2"
type="search"
placeholder="이건 아직 안돼"
aria-label="Search"
/>
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">
검색하기
</button>
</form>
</div>
</nav>
<section class="section">
<h1 class="title">인공지능 동물상 테스트</h1>
<h3 class="subtitle">나는 어떤 동물과 닮았을까?</h3>
<h4 class="sr-only">
본 서비스는 Google의 인공지능 teachable machine 2.0을 활용하였습니다.
</h4>
</section>
<section class="instagram">
<div class="container mb-5 mt-5 instagram-cover d-flex flex-row-reverse">
<img src="img/insta.jpg" alt="" class="instagram-icon" style="width: 5%;" /><a
href="https://www.instagram.com/ssoconut/"
class="mr-2 instagram-link"
>@ssoconut</a
>
</div>
</section>
<script
class="jsbin"
src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"
></script>
<div class="container file-upload">
<div class="image-upload-wrap">
<input
class="file-upload-input"
type="file"
onchange="readURL(this);"
accept="image/*"
/>
<div class="drag-text">
<img src="img/upload.png" class="mt-5 pt-5 upload" />
<h3 class="mb-5 pb-5 pt-4 upload-text">
얼굴 사진을 올려놓거나 눌러서 업로드하세요!
</h3>
</div>
</div>
<div class="file-upload-content">
<img class="file-upload-image" id="face-image" src="#" alt="your image" />
<div id="loading" class="animated bounce">
<div class="spinner-border" role="status">
<span class="sr-only">Loading...</span>
</div>
<p class="text-center">AI가 당신의 동물상을 분석중입니다.</p>
</div>
<p class="result-message"></p>
<div id="label-container" class="d-flex flex-column justify-content-around"></div>
<div id="addThis" class="addthis_inline_share_toolbox_6lz1"></div>
<!-- Go to www.addthis.com/dashboard to customize your tools -->
<div class="addthis_inline_share_toolbox_nqup"></div>
<div class="pt-3 image-title-wrap">
<button
type="button p-2"
class="try-again-btn"
onclick="window.location.reload();"
>
<span class="try-again-text">다른 사진으로 재시도</span>
</button>
</div>
</div>
</div>
<div id="disqus_thread" style="mt-5"></div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function () {
// DON'T EDIT BELOW THIS LINE
var d = document,
s = d.createElement('script');
s.src = 'https://ssoco-facerecognition.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript
>Please enable JavaScript to view the
<a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<hr>
<footer class="footer pt-5 container d-flex justify-content-center">
<div>
<h5>
Made by @ssoconut. Copied 조코딩 JoCoding 2020. All Rights Reserved.</h5>
</div>
</footer>
<footer class="footer pt-5 container d-flex justify-content-center">
<h5>
제작 도움 :
<a href="https://www.youtube.com/channel/UCQNE2JmbasNYbjGAcuBiRRg" style="center; color:red;">조코딩 유튜브 채널</a>
</h5>
</footer>
<footer class="footer pt-5 container d-flex justify-content-center">
<h4>
<a href="https://animalface.site/" style="center">
-> 원본 조코딩 동물상 테스트 바로가기 <-
</a>
</h4>
</footer>
<br>
<br>
<hr>
<!-- 광고부분 -->
<div class="mt-2 container d-flex justify-content-center ad-banner">
<script src="https://ads-partners.coupang.com/g.js"></script>
<script>
new PartnersCoupang.G({ id:312898 });
</script>
</div>
<div class="mt-2 container d-flex justify-content-center ad-banner">
<script data-ad-client="ca-pub-5895911178612874" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
</div>
<div class="mt-2 container d-flex justify-content-center ad-banner">
<ins class="kakao_ad_area" style="display:none;"
data-ad-unit = "DAN-1hv37lj2267nb"
data-ad-width = "320"
data-ad-height = "100"></ins>
<script type="text/javascript" src="//t1.daumcdn.net/kas/static/ba.min.js" async></script>
</div>
<!-- 광고 끝 -->
<script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('.image-upload-wrap').hide();
$('#loading').show(); // 로드되면 로딩창 띄우기
$('.file-upload-image').attr('src', e.target.result);
$('.file-upload-content').show();
$('.image-title').html(input.files[0].name);
};
reader.readAsDataURL(input.files[0]);
init().then(() => {
// console.log('hello');
predict();
$('#loading').hide(); // 다 불러오면 숨긴다
});
} else {
removeUpload();
}
}
function removeUpload() {
$('.file-upload-input').replaceWith($('.file-upload-input').clone());
$('.file-upload-content').hide();
$('.image-upload-wrap').show();
}
$('.image-upload-wrap').bind('dragover', function () {
$('.image-upload-wrap').addClass('image-dropping');
});
$('.image-upload-wrap').bind('dragleave', function () {
$('.image-upload-wrap').removeClass('image-dropping');
});
</script>
<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
// the link to your model provided by Teachable Machine export panel
const URL = 'https://teachablemachine.withgoogle.com/models/FcdwMxASI/';
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();
labelContainer = document.getElementById('label-container');
for (let i = 0; i < maxPredictions; i++) {
// and class labels
labelContainer.appendChild(document.createElement('div'));
}
}
// run the webcam image through the image model
async function predict() {
// predict can take in an image, video or canvas html element
var image = document.getElementById('face-image');
const prediction = await model.predict(image, false);
prediction.sort((a, b) => parseFloat(b.probability) - parseFloat(a.probability));
console.log(prediction[0].className);
var resultTitle, resultExplain, resultCeleb;
switch (prediction[0].className) {
case 'dog':
resultTitle = '귀여운 순둥이 강아지상';
resultExplain =
'누구에게나 다정다감하고 선할 것 같은 당신은 바로 강아지상! 친절하고 활발한 성격으로 어디에서도 인기폭발이며 애교와 웃음이 많아 연인에게 특히나 사랑스럽다. 당신은 애인바라기로 애인의 관심이 부족하면 시무룩해지고 외로움을 타는 모습이 마치 강아지와 똑 닮았다!';
resultCeleb =
'강아지상 연예인: 박보검, 박보영, 박신혜, 손예진, 송중기, 엑소 백현, 워너원 강다니엘';
break;
case 'cat':
resultTitle = '츤데레 매력쟁이 고양이상';
resultExplain =
'무뚝뚝한 당신의 첫인상은 차가워 보이지만 묘한 매력을 풍겨 언제나 인기가 넘친다. 자존심이 세계 1등과 맞먹지만 관심 받는 것을 좋아하고 연인에게는 은근히 애교쟁이다. 시크한 츤데레로 연인에게 끊임없이 설렘을 안겨주는 당신은 고양이상!';
resultCeleb =
'고양이상 연예인: 강동원, 김희선, 엑소 시우민, 뉴이스트 황민현, 이나영, 이종석, 이준기, 차예련, 한예슬';
break;
case 'rabbit':
resultTitle = '천진난만한 매력의 토끼상';
resultExplain =
'천진난만하고 귀여운 당신은 주변 사람들에게 기쁨을 주는 행복바이러스다! 호기심이 많아 활발하며 귀엽고 순수한 외모로 연인의 보호본능을 자극한다. 존재 자체가 상큼한 당신은 특별한 애교 없이도 연인에게 너무나도 사랑스럽다!';
resultCeleb =
'토끼상 연예인: 방탄소년단 정국, 수지, 아이콘 바비, 엑소 수호, 워너원 박지훈, 트와이스 나연';
break;
case 'dinosaur':
resultTitle = '강하지만 따뜻한 공룡상';
resultExplain =
'첫인상은 무심한 성격에 나쁜 사람 같지만, 알고 보면 따뜻함이 묻어나는 당신! 시크한 매력에 선뜻 다가가지 못하지만 한번 다가가면 헤어나올 수 없는 터프한 매력을 가진 카리스마 있는 사람이지 않을까?';
resultCeleb =
'공룡상 연예인: 공유, 김아중, 김우빈, 송지효, 육성재, 윤두준, 이민기, 한지민';
break;
case 'bear':
resultTitle = '포근한 매력의 곰상';
resultExplain =
'첫 인상은 무서워 보이지만 알고 보면 귀여운 매력의 당신! 꼼꼼하고 섬세한 성격으로 연인을 헌신적으로 챙겨주는 당신은 연인에게 듬직한 존재! 포근한 매력에 듬직함까지 갖춘 당신은 훌륭한 사람!';
resultCeleb = '곰상 연예인: 레드벨벳 슬기, 마동석, 안재홍, 조세호, 조진웅';
break;
default:
resultTitle = '알수없음';
resultExplain = '';
resultCeleb = '';
}
var title =
"<div class='" +
prediction[0].className +
"-animal-title'>" +
resultTitle +
'</div>';
var explain = "<div class='animal-explain pt-2'>" + resultExplain + '</div>';
var celeb =
"<div class='" +
prediction[0].className +
"-animal-celeb pt-2 pb-2'>" +
resultCeleb +
'</div>';
$('.result-message').html(title + explain + celeb);
var barWidth;
for (let i = 0; i < maxPredictions; i++) {
if (prediction[i].probability.toFixed(2) > 0.1) {
barWidth = Math.round(prediction[i].probability.toFixed(2) * 100) + '%';
} else if (prediction[i].probability.toFixed(2) >= 0.01) {
barWidth = '5%';
} else {
barWidth = '3%';
}
var labelTitle;
switch (prediction[i].className) {
case 'dog':
labelTitle = '강아지상';
break;
case 'cat':
labelTitle = '고양이상';
break;
case 'rabbit':
labelTitle = '토끼상';
break;
case 'dinosaur':
labelTitle = '공룡상';
break;
case 'bear':
labelTitle = '곰상';
break;
default:
labelTitle = '알수없음';
}
var label =
"<div class='animal-label d-flex align-items-center'>" +
labelTitle +
'</div>';
var bar =
"<div class='bar-container position-relative container'><div class='" +
prediction[i].className +
"-box'></div><div class='d-flex justify-content-center align-items-center " +
prediction[i].className +
"-bar' style='width: " +
barWidth +
"'><span class='d-block percent-text'>" +
Math.round(prediction[i].probability.toFixed(2) * 100) +
'%</span></div></div>';
labelContainer.childNodes[i].innerHTML = label + bar;
}
}
</script>
</body>
<!-- Copyright (c) 2020 by Aaron Vanston (https://codepen.io/aaronvanston/pen/yNYOXR)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -->
</html>