Quarky Machine Learning

配合 Pictoblox 編程及訓練網站 , Quarky 可以在無需額外配件的情況下做到 Machine Learing (機械學習) ,

從而分辨出不同物件/人臉 , 達致AI人工智能。

所需物料 :

Quarky x 1

Pictoblox x 1

具鏡頭的電腦 / 平板 x 1

Pictoblox link (如使用藍牙連接)

USB Type C (如使用USB連接)

連接 Quarky  :

在上方工具列選取「Board」再選擇 Quarky 。

以 USB Type C 或藍牙連接你的 Quarky , 假如使用藍牙請開啟 Picotoblox link。

訓練 Quarky | 進行 Machine Learning :

首先加入 「Machine Learning」 Extension , 按下左下角的「+」號以進入 Extension 頁面。

Mouse Highlight Overlay

加入後會出現 Machine Learning , 按「Create a Model」以進行訓練。

Mouse Highlight Overlay

按下「Create a Model」會導航至「Teachable Machine」這個網頁 ;

選取「Image Project」, 訓練 Quarky 識別並區分圖像。

Mouse Highlight Overlay

緊記選取「Standard image model」 , 這樣才能將 model 載入到 Picotoblox 。

Mouse Highlight Overlay

可選擇「Webcam」或「Upload」來增加圖像樣本 , 「Webcam」是直接使用電腦 / 平板上的鏡頭拍攝 ;

「Upload」則上傳圖像 , 我們建議使用「Webcam」來上傳樣本 , 效率較高。

「Class」代表著物件(需區分的東西) , 假如你要區分多種物件 , 可以「Add a class」來增加。

Mouse Highlight Overlay

長按「Hold to Record」便會保持記錄鏡頭前的圖像 ,建議以不同角度擺放樣本以增加準備性 ,

樣本數愈多精準度亦會愈高!

Mouse Highlight Overlay

拍攝另一組樣本 , 建議選擇2種差異較大的樣本作區分。

Mouse Highlight Overlay

按「Train Model」進行訓練(Machine Learning)

完成訓練後 , 可在網站測試準確度 ;

左圖是Class 2的樣本顯示 100% 正確 , 中間是 Class 1 的樣本顯示100%正確 ,

右圖並不是 Class 1或2的樣本 , 因此並沒出現某個 Class 100% , 只出現一些中間數值代表它被區分成其他東西

i.e. Class 1 , Class 2 以外的東西

測試完 Model 後選擇「Export Model」再點擊「Upload my model」,

目的是取得 model 的 shareable link 以在 Pictoblox中使用。

Image Model - Teachable Machines - Google Chrome

複製 shareable link 至 Pictoblox

PictoBlox
PictoBlox

點擊 「Load a Model」並貼上連結 , 選擇對應的 Model Type 再按「Load Model」

載入 Model 後會出現 Image Model 的 Blocks!

編程教學 :

PictoBlox

首先加入「When Clicked」作 Input , 並加入「Open Recognition window」作圖像識別

PictoBlox

按下綠色旗仔便會出現 Recognition Window , 可擺放 Class 1/2 的樣本到鏡頭前作出區分

PictoBlox

加入 If , 並放進「is identified class from web camera in Class 1?」 ,

then 後則加入 「display 1 with .... at  ... speed」, 當認出 Class 1 時 Quarky 便顯示 「1」

If then 可在 「Control」找到 , identified class 則是 「Machine Learning」的 Blocks ,

display 由 Quarky display 因此可在 「Display」找出它!

PictoBlox

加入區分 Class 2 的編程 , 基本上跟 Class 1 無大分別。

進行測試 :

當 Pictoblox 辨識到 Class 1 或 Class 2 的物件時 , Quarky 便會顯示相對數字 。

以上的 Code 有什麼缺點 ? 或你在區分物件時有發現到問題嗎?

A : 當 Class 1/2 以外的東西放到鏡頭前 , 以上的編程會區分它成數值較高的那一個 Class

例如 : 早前的「奧巴馬」圖片為 Class 1 82% , 它便會區分成 Class 1。

進階編程 :

PictoBlox

利用「Get confidence of class」來判斷輸入的圖象是什麼 , confidence of class 1/2 愈高代表它愈有機會是 class 1/2

綠色的比較 blocks 可以在「Operators」中找出 , default 為「 ___ > 50」

PictoBlox

百分比代表 confidence的強度 , 換算到編程時需化作小數 i.e. 55% --> 0.55

加入第3類結果 :

利用「and」及比較來區分 class 1 , 2 以外的東西 ;

當兩者的 confindence 都小於 0.95時 (強度不足以區分成class 1/2) Quarky 便 display "what is this?"

整個編程 :

PictoBlox