2023年8月1日 星期二

LabelImg 的安裝與使用


LabelImg Tool:  Annotations are saved as XML files in PASCAL VOC format, the format used by ImageNet. Besides, it also supports YOLO and CreateML formats.


下載 LabelImg ,  
git clone https://github.com/HumanSignal/labelImg.git

若沒有Python Qt, 則須安裝好QT5 
  
pip install pyqt5_tools

接著再執行label Image 的工具
#For QT5 use this command,
pyrcc5 -o libs/resources.py resources.qrc
python labelImg.py


對某一個物件在所有圖片都標注完之後(記得存檔), 再回頭來標注另一個物件會比較快, 因為每框選一個物件,都要從下拉選擇選擇label 反而比較花時間!一個圖檔可能會有多個物件, 這些框選的資訊都記錄在對應的.txt 中。1.jpg -------> 1.txt2.jpg -------> 2.txt3.jpg -------> 3.txt .... ....
在yolo 模型, 其.txt 檔的內容, 每一列代表一個框框的資訊, 但以normalized的資訊來表示. 框框的物件座標資訊(x,y,w,h)都是相對於原始圖片的長宽,所以這些座標資訊都是介於0~1的數字class_id x y w hclass_id x y w h....#轉成0~1def convert(size, box): dw = 1./(size[0]) #圖片的寛 dh = 1./(size[1]) #圖片的高 x = (box[0] + box[1])/2.0 - 1 y = (box[2] + box[3])/2.0 - 1 w = box[1] - box[0] h = box[3] - box[2] x = x*dw w = w*dw y = y*dh h = h*dh return (x,y,w,h)
#yolo偵測到的物件其座標資訊須再乘回比例才可以得到原始圖片的座標資訊=========LabelImg 快速鍵,可以加快你標記的速度
Ctrl + uLoad all of the images from a directory
從目錄加載所有圖像
Ctrl + rChange the default annotation target dir
更改默認註釋目標目錄
Ctrl + sSave  儲存
Ctrl + dCopy the current label and rect box
複製當前標籤和框
Ctrl + Shift + dDelete the current image
刪除當前圖像
SpaceFlag the current image as verified
將當前圖像標記為已驗證
wCreate a rect box
創建一個框
dNext image  下一張圖片
aPrevious image  上一張圖片
delDelete the selected rect box
刪除選中的矩形框
Ctrl++Zoom in  放大
Ctrl–Zoom out  縮小
↑ → ↓ ←Keyboard arrows to move selected rect box




"Flag the current image as verified" ,會出現綠色背景, 讓你可以快速事後檢查有沒有可能有遺漏的標記。
若有綠色背景, 表示你已驗證過這張圖片已經檢查過了.