> For the complete documentation index, see [llms.txt](https://activities.kittenbot.hk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://activities.kittenbot.hk/aimask/aimasktechnicalsupport.md).

# 口罩佩戴AI模型訓練與辨認 (機器學習)示範

參與者可以利用KOI 機器學習功能, 通過對KOI AI 鏡頭進行訓練, 讓KOI 在辨認模式中, 分辨出鏡頭前的人面是否有配把配戴口罩。

### KOI 機器學習的訓練與辨認概念

#### 模型訓練:

把戴有口罩的人面影像 及 沒有配帶口罩人面的影像, 分別儲到2個分類, 並儲存到KOI 的SD card 中。

#### 辨認模式:

KOI 會根據訓練所得的模型資訊, 判斷在鏡頭前的影像是屬於那一個分類。

### 編程平台

Microsoft MakeCode **<https://makecode.microbit.org/>**

#### 有用插件

Kittenbot Robotbit 擴展板 **<https://github.com/KittenBot/pxt-robotbit>**

Kittenbot Armourbit 擴展盒 **<https://github.com/KittenBot/pxt-powerbrick>**

KOI **<https://github.com/KittenBot/pxt-koi>**

### 編程示範與解說

#### **機器學習2步曲**

1. 分類模型訓練
2. 運行分類器 - 辨認模式

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_03.jpg)

#### **示範器材接線**

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_04.jpg)

#### **1. 分類模型訓練**

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_05.jpg)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_06.jpg)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_07.jpg)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_08.jpg)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_09.jpg)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_10.jpg)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_11.jpg)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_12.jpg)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_13.jpg)

**\*\*訓練參考程式:** [**https://makecode.microbit.org/\_fozKmF7sV3jd**](https://makecode.microbit.org/_fozKmF7sV3jd) **\*\***

**訓練示範 Youtube:** [**https://youtu.be/CD-KRfKVDKc**](https://youtu.be/CD-KRfKVDKc)

#### 2. **運行分類器** - 辨認模式[](https://kittenbothkcompetition.readthedocs.io/en/latest/aiMask/AiMaskTechnicalSupport.html#id9)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_14.jpg)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_15.jpg)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_16.jpg)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_17.jpg)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_18.jpg)

![](https://kittenbothkcompetition.readthedocs.io/en/latest/_images/MaskedORNot_19.jpg)

**\*\*\*\*辨認參考程式:** [**https://makecode.microbit.org/\_g5rU25gYcKYo**](https://makecode.microbit.org/_g5rU25gYcKYo) **\*\***

**辨認示範 Youtube:** [**https://youtu.be/Z4Ce5h6rGqs**](https://youtu.be/Z4Ce5h6rGqs)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://activities.kittenbot.hk/aimask/aimasktechnicalsupport.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
