# \[인공지능] 티처블 머신 사용하기

### 코드

{% code title="인공지능 모델을 불러올 때" %}

```
@인공지능 "링크" 불러오기
```

{% endcode %}

{% code title="카메라로 사진을 찍을 때" %}

```
@카메라 사진찍기
```

{% endcode %}

{% code title="카메라로 찍은 사진을 인공지능 모델로 분류할 때" %}

```
@인공지능 {인공지능_모델} 로 {찍은_사진} 분류하기
```

{% endcode %}

***

### 설명

티처블 머신(Teachable Machine)에서 공유한 인공지능 모델을 불러오고, 카메라로 촬영한 사진을 해당 모델로 분류할 수 있어요.

\
`@카메라 사진찍기`를 실행하면 카메라가 켜지고, 3초 후 촬영된 사진이 변수에 저장돼요.\
사진을 분류하면 결과가 **딕셔너리 형태**로 반환돼요.\
딕셔너리에는 각 분류 항목(클래스)과 해당 항목일 확률 값(0\~1 사이의 실수)이 함께 저장돼요.

인공지능 모델을 불러오거나 사진을 분류하는 과정에서는 네트워크 및 연산 처리로 인해 약간의 시간이 걸릴 수 있어요.

***

### 주의사항

* 인공지능 분류 결과는 딕셔너리로 반환돼요.
* 불러오는 티처블 머신 링크는 인공지능 모델이 포함된 유효한 주소여야 해요.
* 사진 촬영과 분류 과정에서 결과를 받아오기까지 약간의 시간이 걸릴 수 있어요.

***

### 파이썬 대응 코드

인공지능 코드는 파이썬에 대응되는 코드가 없어 제공되지 않아요.

***

### 예시

{% code title="예시 코드" %}

```
하랑이_분류모델 = @인공지능 "https://teachablemachine.withgoogle.com/models/모델/" 불러오기

찍은_사진 = @카메라 사진찍기
분류_결과 = @인공지능 하랑이_분류모델 로 찍은_사진 분류하기

분류_결과 보여주기
```

{% endcode %}

{% code title="예시 코드의 결과" %}

```
(인공지능 모델을 불러와서 하랑이_분류모델 변수에 저장해요.)
(카메라로 찍은 사진을 찍은_사진 변수에 저장해요.)
(인공지능_모델로 찍은_사진을 분류한 결과를 분류_결과 변수에 딕셔너리 형태로 저장해요.)
{
	공부하는 하랑이: 0.9449184536933899
	신난 하랑이: 0.0017847634153440595
	졸린 하랑이: 0.0045095933601260185
	슬픈 하랑이: 0.04878726229071617
}
```

{% endcode %}

{% code title="특정 항목(클래스)의 분류 결과를 확인할 때" %}

```
분류_결과["공부하는 하랑이"] 보여주기
분류_결과['슬픈 하랑이'] 보여주기
```

{% endcode %}

{% code title="특정 항목(클래스)의 분류 결과를 확인할 때의 결과" %}

```
0.9449184536933899
0.04878726229071617
```

{% endcode %}

***

### 검색 키워드

AI, 인공지능, 이미지 분류, 티처블 머신, 카메라, 머신러닝


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://codebook.horang.it/ai/undefined.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
