# Sugar Cam功能教學: Teachable Machine模型訓練

### Teachable Machine網上模型訓練

前往Teachable Machine的官網。

[Teachable Machine with Google](https://teachablemachine.withgoogle.com/train)

<figure><img src="https://879637118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6uJvpXC43onNIIwhMlWo%2Fuploads%2FSV7rf1eMCKEn35vG6IF0%2Fimage.png?alt=media&#x26;token=83d83dfb-a132-4ba3-990f-f16867f5ec68" alt=""><figcaption></figcaption></figure>

開啟Image Project，選擇Embedded Image Model。

<figure><img src="https://879637118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6uJvpXC43onNIIwhMlWo%2Fuploads%2FmQhSQlzzYu0h2TTaPlwp%2FScreenshot%202023-08-11%20114838.png?alt=media&#x26;token=cef3dbcb-fed9-4bf9-8f61-d12f4ab1c88c" alt=""><figcaption></figcaption></figure>

訓練模型時需要使用Sugar Cam的畫像，首先選擇Device然後按Connect，成功的話畫框內會出現Sugar Cam的畫面，此時就可以開始錄入圖像。

{% hint style="info" %}
這個Teachable Machine最多支援8個分類，每個分類暫時未發現相片上限，一般40\~50張相已經很足夠。

Teachable Machine只可使用黑白相片訓練，而且解像度只是96x96，所以請確保訓練的物件輪廓清晰並有較大分別。
{% endhint %}

<div data-full-width="true"><figure><img src="https://879637118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6uJvpXC43onNIIwhMlWo%2Fuploads%2FZiEMjaNABfYom6Ure9cc%2Fd.gif?alt=media&#x26;token=4098d3bd-d83b-41e2-8495-533b75305ec4" alt=""><figcaption></figcaption></figure></div>

然後按Train Model。完成後可以Connect Device，驗證模型的準確度。

<div><figure><img src="https://879637118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6uJvpXC43onNIIwhMlWo%2Fuploads%2FfTxfRi9w7FlaC0SbP87b%2Fimage.png?alt=media&#x26;token=ba8d1d58-539b-4256-8ad4-1980f601b399" alt=""><figcaption></figcaption></figure> <figure><img src="https://879637118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6uJvpXC43onNIIwhMlWo%2Fuploads%2F6zvoUFn3ichGr61Pekfe%2Fimage.png?alt=media&#x26;token=f14c4478-fe5d-44b9-8216-087310f678f7" alt=""><figcaption></figcaption></figure> <figure><img src="https://879637118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6uJvpXC43onNIIwhMlWo%2Fuploads%2FYYiXIjOhscDIMGKX5UXt%2Fimage.png?alt=media&#x26;token=6241dad6-1fe2-46a9-ab49-add24c232fce" alt=""><figcaption></figcaption></figure></div>

### Teachable Machine模型匯出

滿意模型的準確度後就可以匯出模型檔案。按Export Model，然後選擇TensorFlow Lite，選擇TensorFlow Lite for Microcontrollers。按Download my Model。

<figure><img src="https://879637118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6uJvpXC43onNIIwhMlWo%2Fuploads%2Fa7ge1sypTO3ThySFGEb6%2Fimage.png?alt=media&#x26;token=2d7af067-90c2-4856-b4b1-30b73bc90a2d" alt=""><figcaption></figcaption></figure>

完成後你會下載一個名為converted\_tinyml.zip的檔案。

<figure><img src="https://879637118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6uJvpXC43onNIIwhMlWo%2Fuploads%2FeTiYww650PyiSpEYRipZ%2Fimage.png?alt=media&#x26;token=c03b44cd-43b9-4a87-baaa-a3027291f67f" alt=""><figcaption></figcaption></figure>

然後回到Teachable Machine小程式，將模型檔案上傳到Sugar Cam。完成後再按Connect，Sugar Cam辨認的結果會顯示在小程式的左下方。

<figure><img src="https://879637118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6uJvpXC43onNIIwhMlWo%2Fuploads%2F3WLuqc7v4S9p3LrxDOhe%2Fdd.gif?alt=media&#x26;token=0e2c5671-e456-47df-907a-c36f671a671f" alt=""><figcaption></figcaption></figure>


---

# 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://sharinghub.kittenbot.hk/functional_modules/sugar/sugarcam/teachablemachine/training.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.
