✔ 인공지능, 머신러닝, 인공 신경망 알고리즘
- 인공 지능 - 인간의 지적 능력을 기계나 컴퓨터를 이용해서 인공적으로 구현, 컴퓨터가 인간처럼 학습하고 행동하는 기술 (ex. 알파고)
- 머신러닝 - 많은 양의 데이터를 기계가 학습하는 과정
- 인공 신경망 알고리즘 - 머신러닝에서 인간처럼 뇌의 신경망 구조를 모방한 알고리즘 사용
1) 티처블 머신에서 인공지능 만들기
2) 데이터 등록 (200장 이상 샘플 이미지 촬영)
3) 모델 학습 시키고 테스트
4) 모델을 티처블 머신에 업로드
# 공유 가능한 링크
https://teachablemachine.withgoogle.com/models/q1urCXww_/
# 모델에서 사용할 코드 스니펫
<div>Teachable Machine Image Model</div>
<button type="button" onclick="init()">Start</button>
<div id="webcam-container"></div>
<div id="label-container"></div>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.3.1/dist/tf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@teachablemachine/image@0.8/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/q1urCXww_/";
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();
// 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"));
}
}
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
const prediction = await model.predict(webcam.canvas);
for (let i = 0; i < maxPredictions; i++) {
const classPrediction =
prediction[i].className + ": " + prediction[i].probability.toFixed(2);
labelContainer.childNodes[i].innerHTML = classPrediction;
}
}
</script>
5) HTML 파일에 자바스크립트 코드 넣기
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>인공지능 과일 도감</title>
</head>
<body>
상단 인공지능 모델 코드 붙여넣기
</body>
</html>
6) 웹 브라우저에서 실행
1) 구글 이미지 검색
2) 크롤링 작업 위한 셀레늄 설치
(Do it) 조코딩의 프로그래밍 입문