發表文章

[imageAI]What is the step number displayed in the log messages during custom object detection training.

圖片
For most people using imageAI to implement the object detection application, they probably reference the tutorial " imageAI : Custom Detection Model Training " on the official website. When people begin the training by the sample from the tutorial, the progress bar displayed with some numbers in the log message. Apart from the "Epoch", there are information about time and step but what is the "step" numbers mean? The step numbers  are counted from 0 in each Epoch. For people who have basic machine learning knowledge, they could think of the batch numbers (all training instances divided by batch size)  immediately .  However, it seems something different from the batch number. my case: -data set: 301 images with 3 types labels -batch size:4 -Epoch:12 I noticed the difference when I training a data set containing 301 images with batch size 4. I thought the number before the progress bar should be the total of the batch number "73" (301/4) and the c

Let's start to understand the ImageAI!!

圖片
ImageAI is a fantastic python library that allows users to create it's own computer vision application in a short term. In fact, most features in ImageAI are made up of functions in KERAS and openCV. So from my point of view, understand the source is a great way to learn how those powerful libraries , and artificial intelligence as well. Although you can install the python package by PIP and trace the source that package included, download the source from the GitHub and test it without PIP install could be a better idea for study and test it. The reason is that we could modify the code or add debug messages in the source. It could break the original functions in the package. So I suggest test it in an isolation environment and use it without PIP install. Create a new "Evironments" without the imageAI  package in ANACONDA Install the essential for the imageAI -tensorflow 1.15.0 (PIP3) -keras 2.3.1 (PIP3) -opencv 4.0.1 (Anaconda) -pillow 7.1.2 (

ANN手勢辨識猜拳機器人

圖片
最近工作單位的老師希望可以實作一個機器人範例,其主要是可以整合機電實做和機器學習,做一個可以與人類猜拳的機器人 起初老師的構想是可以用影像辨識的方式來讓機器人可以偵測人出拳的手勢(石頭,剪刀或布).但考量到我本身的影像辨識熟練度不高,樣本蒐集和機器學習的時間也都很花時間. 雖然我也覺得影像辨識類的範例可能比較容易激起學生的興趣,但如果省略掉樣本蒐集和機器學習這些比較枯燥的步驟,似乎課堂上知識面內容又過於薄弱. 因此我的想法是初版的機器人範例先不要用影像,而是以感知機為基礎建立一個多層的人工神經網路,將每隻手指的彎曲度(彎曲感測器)做為輸入,用來判斷可能的手勢.這個題目本身在資料蒐集和機器學習的時間可以大幅化簡,但卻還是保留. 系統流程: 大致上來說,整個遊戲的流程會由使用者按下"開始"鈕開始.經過3秒鐘的倒數計時,機器人本身會用亂數決定一個手勢(剪刀,石頭,或布)並將機器手移動成該手勢.此時機器人也會檢查使用者的手勢,並決定遊戲勝負,最後則更新記分板. 系統架構: Arduino Uno: 機器人運作控制核心 Servo:帶動機械運動的伺服機馬達 FlexSensor: 用來偵測手指彎曲程度的感測器 (可參閱  https://madeinti.blogspot.com/2020/04/blog-post.html ) User Interface: 遊戲啟動按鈕,分數提示...等 輸入及顯示裝置 記分板, 左邊數字為機器人勝場數,右方為玩家的勝場數 機器手機構設計: 為了簡化設計,雖然人有5支手指,但對於猜拳遊戲來說,我們可以把"食指中指"及"無名指小指"視為兩個群組,而大拇指獨立一組.所以我們可以用3個伺服機就能表現出猜拳的三種動作. 硬體完成: ANN人工神經網路-Arduino實做: 我們在Arduino中實做出上圖的網路架構,以食指,無名指和大拇指的彎曲感測做為網路輸入,最終輸出石頭,剪刀,布三種手勢的輸出權重. 使用陣列資料結構描述網路架構, 陣列中將每個節點輸

ImageAI 口罩辨識練習-樣本製作篇

圖片
前情提要,關於口罩配戴辨識練習: https://madeinti.blogspot.com/2020/05/imageai.html 樣本是什麼,我挑了怎樣的樣本 用來給電腦做機器學習的輸入資料,以是否有配戴口罩的辨識應用為例,我選擇了"有戴口罩的臉"和"沒戴口罩的臉".另外也有確保兩種類別都有有無配戴眼鏡的影像. 之所以選擇"有沒有戴口罩的臉"而非選擇"口罩"或是"人臉",主要的原因在於希望避免影像中有出現口罩就會被偵測到的情形. 有戴口罩,有戴眼鏡 沒戴口罩,沒戴眼鏡 有戴口罩,沒戴眼鏡 沒戴口罩,有戴眼鏡 樣本上哪找?要多少張? 如果以這個口罩辨識的練習來說,我的作法是在google上搜尋face, mask...等這類的關鍵字,並選擇搜尋圖片的功能,然後再一張一張下載.如有需要,建議也可以在搜尋圖片中指定圖片的大小.另外要注意的是圖片的格式,基本上jpg,png對於後續進行樣本製作或機器學習都沒太大的問題,但有些格式可能就要注意,例如我曾有幾張webp影像,樣本做得出來,但在學習過程中一直有些問題. 最後關於張數的問題,基本上當然是愈多愈好,但我覺得這跟選擇的圖片內容也有關係,這點我也還在摸索中~~@@.至於這個口罩辨識練習,可以下載我蒐集的樣本圖,總共284張,自行看看張數和內容. https://drive.google.com/file/d/1lvP8jp6I7JcIOxnMJf9v9x7V2-5b7Bou/view?usp=sharing ImageAI YoloV3樣本資料集: 要將樣本用ImageAI 的範例進行object detection的機器學習,需將樣本整理成如下的檔案格式.我們先看"train"資料夾,內含"images"和"annotations"兩個子資料夾.理論上可以將蒐集到的影像全部丟進去.至於"annotations"則是"images"資料夾中每一張影像的標籤檔,基本

ImageAI-口罩辨識練習

圖片
ImageAI官網有附custom object detection的範例, 相信因該蠻多人都希望可 該範例跑自己想要的物件辨識.最近剛好遇到"covid-19"疫情.就以口罩配戴為例進行練習. 系統架構及概念: ".h5"和"json檔"為依照蒐集到的樣本學習完成後的YoloV3描述檔和設定檔,以我們的應用來說,要學習的目標為 "有戴口罩的臉" 和 "沒戴口罩的臉" .詳細的樣本製作和學習方式,我們會再另外再討論.這邊就以我先訓練好的檔案為例. 程式範例及解說我放在google colab中,大家可以自行在上面測試範例和修改,(順便幫我改改英文和國文~~).裡面也有附已經訓練好的YoloV3檔案. google colab連結: https://colab.research.google.com/drive/1NB-_CHR-LOW7sRJ63DrH5kF1yepMHVjT?usp=sharing 關於樣本的蒐集: https://madeinti.blogspot.com/2020/05/imageai_8.html 參考資料: https://github.com/OlafenwaMoses/ImageAI/blob/master/imageai/Detection/Custom/CUSTOMDETECTION.md

土製體感手套+伺服機

圖片
概念: 透過FlexSensor因彎曲改變類比電壓來判斷人手彎曲的程度, 經過Arduino分析後, 將對應的角度位置命令送往伺服機,使伺服機的轉動角度可以由手套來決定 FlexSensor貼在手套上 系統架構: 原型成品: 測試影片: 一些心得: 1.Flexsensor阻質變化或是人每隻手指的彎曲特性不同,建議每隻手指的FlexSensor最好能獨立校正 2.MG966R Servo, 兩顆以上似乎Arduino的regulator輸出因該就不夠力了,三顆以上可能獨立接4顆AA電池也是無法正常動作. -20200404補充: 使用一6.2V/2A變壓器供電後,接三顆馬達動作就正常了,量測電流曾出現過1.6A 相關資源: FW,腳位定義,系統架構,: https://github.com/NAERSTEAM/EELAB/tree/master/Project_GlovedControlRobot_20200401_0 Servo轉板電路: https://github.com/NAERSTEAM/EELAB/tree/master/Module_20200402_0_ServoAdapter FlexSensor轉板電路: https://github.com/NAERSTEAM/EELAB/tree/master/Module_20200402_1_FlexSensorAdapter

[EAGLE]切換設定語言

預設的狀況下EAGLE會自動判斷作業系統環境選擇適合的語言.以我的繁體中文Windows10來說,EAGLE會自動幫我設定成簡體中文(沒有繁體版?).但為了方便和英文的教學資源對照,所以我是偏好設定成英文顯示. 不過在EAGLE中找了很久都沒發現更換語言的選項.經由官網討論區的文章.找出下列方式 步驟 1.切換到windows的command line. 2.SET LANG=en_GB  3.cd C:\Program fiee\eagie-9.x.x (前往eagie.exe所在目錄,大家的電腦或版本可能都不一樣) 4.start eagle.exe   (記得要start, 不能只跑執行檔喔) 參考: https://forums.autodesk.com/t5/eagle-forum/ui-language-settting/td-p/6894912