# AUO實習週報
## 0704-0708學習週報
By 黃安華 and 陳柏融
### 目錄
- PyQt5
- pyqtSignal
- qtdesigner
- multiprocessing
- qthread
### PyQt5
- GUI設計
### PyqtSignal
- 自定義信號
- 以emit()做信號的發射
- 以connect()連接發射與接收
### QtDesigner
- 更便於設計GUI的工具,不需要寫好一次次執行確認位置
- 以拖拉式做處理
- 直接使用powershell 輸入指令轉檔 ui-->py
- 指令: pyuic5 -x (qtdesign檔名).ui -o (轉檔後檔名).py
- 轉檔後的檔案會放在同一個資料夾
### Multiprocessing
使用時機:
- 當一個process(行程)可能會占用很久時間,或是重複執行不會關閉
- 讓程式得以背景執行,不會使電腦卡在同一個步驟無法做其他事情造成沒有回應
### QThread
Pyqt
## 0711-0715學習週報
### 目標
物件偵測訓練介面(YOLOv5)、覆判重框(labelme)介面與功能
### Day1
- 覆判重框介面設計
### Day2
- 嘗試介面對接(以ui連接功能)
- 更新介面(有缺)
- 使用AiWRDD試跑氣泡檢測訓練
### Day3
- 了解PFL AiWRDD架構
- 製作甘特圖
- 介面改成用ROIWidget去改
- 可匯入資料夾到recepiList
- further: 測試滾動等其他功能
### Day4
- 可新增、刪除、清空分類顯示在左側(但沒有功能只有顯示)
- W2229週報
#### Note
json-->yolo處理放preprocess資料夾
#### BUGS:
- 非bmg顯示不了-->路徑?
- 如何儲存非固定數量變數
- 無法儲存形狀
### Day5
- 可以匯入檢視bmp、jpg、png的圖片
- 可在同一個class新增label(同個名字)
- 可以畫框,顏色隨機(相同class同個顏色)
- 刪除class會把label一起刪除(但圖上沒有)
#### Targets:
設置儲存標記的位置,切換圖片時呼叫-->之後直接儲存到json
shape_new_class要隨著不同檔案更改變數(名字是class),每個圖存不同json
刪除類別要一起刪標記
不選擇任何class要限制不能標記
重新標記-->連結label刪掉當前標記再呼叫畫一次
清除時可以一併清除所有標記
#### 問題:
如何儲存非固定數量變數
顯示當前選擇label?
鍵盤控制?ex:Enter?
## 0718-0722學習週報
### Day1
- Sucessful pop up dialog after labeling
- Discuss and Update GUI
- Validation Status (just labels)
- Alarm checkbox
#### TODO
- **HOW TO DELETE SHAPES ON CANVAS**
- labels and shapes' variables
- dialog GUI editing & functions
- validation functions
- load and generate json file
- save to validate / don't consider if press clear
### Day2
- Pop up dialog to add a new label
- auto input images(by setting path manually in the code)
- could read json but not see the labels on canvas
- other bugs caused by different input
#### TODO
- labels and shapes' variables
- **HOW TO DELETE SHAPES ON CANVAS**
- New feature: chossing existing class name/ image fit window
- - choose first then add
- Save and read shapes by json (loadshapes & loadlabels function)
- validation functions
- save to validate / don't consider if press clear
#### Informations
shapes = [
dict(
label=s["label"],
points=s["points"],
shape_type=s.get("shape_type", "polygon"),
flags=s.get("flags", {}),
group_id=s.get("group_id"),
other_data={
k: v for k, v in s.items() if k not in shape_keys
},
)
for s in data["shapes"]
]
shape_list [<shape.Shape object at 0x000002645BC67100>]
label_list_item ('123 (0)', <shape.Shape object at 0x000002645BC67100>)
### Day3
- 設定預設標記類別為前一個輸入的內容
- 刪除標記警示
- 介面完成進度%回報
- 了解PFL專案與程式碼:PFL Bubble專案 平展 回控 報告 管理
- 看起來刪除圖形有點進度了?
#### TODO
- find shape in list by listwidget
- 存的json是空白的
- Exit label mode?(Not able to choose shape)
- validation functions
- save to validate / don't consider if press clear
### Day4
- 刪除圖形
- PFL retrain判定與後續維持說明
- 全部清除按鈕功能完成
- 同個類別標示第幾個label
- W2230週報
#### TODO
- PFL Refresh 頁面,當沒有匯入資料時pass 跟ng無功能
- 存的json是空白的
- Exit label mode?(Not able to choose shape)
- validation functions
- - save to validate / don't consider if press clear
#### Informations
YOLO讀檔-->labelme矩形-->標記&轉檔YOLO-->YOLO Retrain
矩形-->YOLO
多邊形-->語意分割
### Day5
- 刪除類別+刪除類功能警示
- 週報
- 修正Bug
- - 刪除某個label之後刪除類別出錯(某些東西沒刪導致list out of range?)
- - 未輸入名字的形狀清除
- - 刪除某個label之後後面數字不會更新
- 10.36.36.131
- 找到怎麼存shape
#### TODO
- **儲存功能**-->把class跟shape用labelme格式存json
- 修正AiWRDD_PFL bug: PFL Refresh 頁面,當沒有匯入資料時pass跟ng無功能 -->Host_IP讀不到
- Auto save: 切換圖片/PassNG-->參考App.py / labelfile.py
- 編輯標記: 退出標記模式
- 多邊形標記
## 0725-0729學習週報
### Day1
#### PFL problems:
- 驗證按下NG或OK就自動跳下一張
- chip ID顯示不完全 (已解決未上傳)
- 如果沒東西不會刷新,按pass ng會當機
#### PFL
- 製作假圖retrain,解決誤判問題
#### Labelme覆判
- 參考labelme儲存方式儲存標記檔案
- 初步存檔(沒有換行,沒有label/shape的資料)
- 警報聲
### Day2
#### Labelme覆判
- 可存長方形、多邊形標記(還不能讀檔)
- 多邊形標記功能
- 可編輯標記
- 顯示Chip ID
- 點選標記的名稱顯示在右上角
#### TODO
- Auto save: 切換圖片/PassNG-->參考App.py / labelfile.py
- json讀檔
##### PFL problems:
- 驗證按下NG或OK就自動跳下一張(新功能)
- 如果沒東西不會刷新,按pass ng會當機
### Day3
#### Labelme覆判
- 連續刪兩個label bug(已解決)
- 讀檔位置正確但名稱不對
- 切換讀檔時右邊標記會無限增加(已解決)
#### TODO
- Auto save: 切換圖片/PassNG-->參考App.py / labelfile.py
##### PFL problems:
- 驗證按下NG或OK就自動跳下一張(新功能)
- 如果沒東西不會刷新,按pass ng會當機
##### bug
- 讀不到兩個以上
- labellist增加到10以上不會更新數字
### Day4
- 已解決讀檔bug,可自動顯示於旁邊的list
- Auto save:切換圖片/PassNG
- 驗證功能:待物件偵測完成接上
- 週報
#### TODO
- 了解YOLO
- 物件偵測GUI
##### PFL problems:
- 驗證按下NG或OK就自動跳下一張(新功能)
- 如果沒東西不會刷新,按pass ng會當機
### Day5
- YOLOv5 research
#### (YOLO)predict.py
~~~
Traceback (most recent call last):
File "D:/Projects/aiwrdd/deeplearning/object_detect/yolov5/predict.py", line 109, in <module>
predictor = YoloV5Predictor(weights, 224, 0.25, 0.45, device='0')
File "d:\projects\l8bd1_yolov5\yololib\predictor.py", line 35, in __init__
self.device = select_device(device)
File "d:\projects\l8bd1_yolov5\yolov5_utils\torch_utils.py", line 62, in select_device
assert torch.cuda.is_available() and torch.cuda.device_count() >= len(device.replace(',', '')), \
AssertionError: Invalid CUDA '--device 0' requested, use '--device cpu' or pass valid CUDA device(s)
~~~
## 0801-0805學習週報
### Day1
YOLO_train_widgets.py
- YOLOv5s try training(只能用最低配置batchsize=1,epoch=1)
- 初步GUI架構
#### TODO
- TrainThread
- 變數名稱+configs修改
https://shengyu7697.github.io/python-write-ini-file/
- 套上pretrain json轉YOLO訓練
- PFL報告
##### 參考:
relabel.py
PKL_Relabel.py
classify_train_widgets.py
classify_train_widgets_ui.py
##### YOLOv5
yolo2labelme.py
predict.py
trainer.py
#### 第一次訓練結果:
~~~
YOLOv5 e9491ff Python-3.8.7 torch-1.8.1+cu111 CPU
hyperparameters: lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0
Overriding model.yaml nc=80 with nc=3
from n params module arguments
0 -1 1 3520 models.common.Conv [3, 32, 6, 2, 2]
1 -1 1 18560 models.common.Conv [32, 64, 3, 2]
2 -1 1 18816 models.common.C3 [64, 64, 1]
3 -1 1 73984 models.common.Conv [64, 128, 3, 2]
4 -1 2 115712 models.common.C3 [128, 128, 2]
5 -1 1 295424 models.common.Conv [128, 256, 3, 2]
6 -1 3 625152 models.common.C3 [256, 256, 3]
7 -1 1 1180672 models.common.Conv [256, 512, 3, 2]
8 -1 1 1182720 models.common.C3 [512, 512, 1]
9 -1 1 656896 models.common.SPPF [512, 512, 5]
10 -1 1 131584 models.common.Conv [512, 256, 1, 1]
11 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
12 [-1, 6] 1 0 models.common.Concat [1]
13 -1 1 361984 models.common.C3 [512, 256, 1, False]
14 -1 1 33024 models.common.Conv [256, 128, 1, 1]
15 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
16 [-1, 4] 1 0 models.common.Concat [1]
17 -1 1 90880 models.common.C3 [256, 128, 1, False]
18 -1 1 147712 models.common.Conv [128, 128, 3, 2]
19 [-1, 14] 1 0 models.common.Concat [1]
20 -1 1 296448 models.common.C3 [256, 256, 1, False]
21 -1 1 590336 models.common.Conv [256, 256, 3, 2]
22 [-1, 10] 1 0 models.common.Concat [1]
23 -1 1 1182720 models.common.C3 [512, 512, 1, False]
24 [17, 20, 23] 1 21576 models.yolo.Detect [3, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]]
YOLOv5s summary: 270 layers, 7027720 parameters, 7027720 gradients
Transferred 348/349 items from D:\Projects\yolov5\runs\best.pt
Scaled weight_decay = 0.0005
optimizer: SGD with parameter groups 57 weight (no decay), 60 weight, 60 bias
train: Scanning 'D:\Projects\ct1\yolov5\dataset\labels\train.cache' images and labels... 2239 found, 0 missing, 681 empty, 1 corrupt: 100%|██████████| 2239/2239 [00:00<?, ?it/s]train: WARNING: D:\Projects\ct1\yolov5\dataset\images\train\K58G5KA_L48_1_top_770_-50_970_50_1130_940_5490_4390.jpg: ignoring corrupt image/label: negative label values [ -0.21758 -0.21219]
train: Scanning 'D:\Projects\ct1\yolov5\dataset\labels\train.cache' images and labels... 2239 found, 0 missing, 681 empty, 1 corrupt: 100%|██████████| 2239/2239 [00:00<?, ?it/s]
val: Scanning 'D:\Projects\ct1\yolov5\dataset\labels\val.cache' images and labels... 556 found, 0 missing, 166 empty, 0 corrupt: 100%|██████████| 556/556 [00:00<?, ?it/s]
Plotting labels to D:\Projects\yolov5\runs\ct1\labels.jpg...
AutoAnchor: 3.78 anchors/target, 1.000 Best Possible Recall (BPR). Current anchors are a good fit to dataset
Image sizes 224 train, 224 val
Using 0 dataloader workers
Logging results to D:\Projects\yolov5\runs\ct1
Starting training for 1 epochs...
Epoch gpu_mem box obj cls labels img_size
0/0 0G 0.01782 0.004968 0.001431 1 224: 100%|██████████| 2238/2238 [05:34<00:00, 6.69it/s]
Class Images Labels P R mAP@.5 mAP@.5:.95: 100%|██████████| 278/278 [00:12<00:00, 21.86it/s]
all 556 390 0.975 0.978 0.988 0.696
1 epochs completed in 0.097 hours.
Optimizer stripped from D:\Projects\yolov5\runs\ct1\weights\last.pt, 14.3MB
Optimizer stripped from D:\Projects\yolov5\runs\ct1\weights\best.pt, 14.3MB
Validating D:\Projects\yolov5\runs\ct1\weights\best.pt...
Fusing layers...
YOLOv5s summary: 213 layers, 7018216 parameters, 0 gradients
Class Images Labels P R mAP@.5 mAP@.5:.95: 100%|██████████| 278/278 [00:11<00:00, 23.89it/s]
all 556 390 0.975 0.978 0.988 0.696
mura 556 92 0.93 0.989 0.975 0.683
agm_mura 556 139 0.996 0.986 0.994 0.747
light_mura 556 159 1 0.96 0.995 0.658
~~~
### Day2
- 訓練GUI大致完成
- 設定遠端電腦環境
#### 遠端訓練
PFL:
10.37.148.32
帳號: AUO/User
密碼: fab$PUBLIC03
跑物件偵測:
10.37.146.22
CKCGLC07\test
fab$PUBLIC01
### Day3
- 訓練結束設定- 可以結束但直接整個程式結束掉了
- 製作小資料夾讓測試快一點
- 討論轉檔/標記
- 閱讀yololib/trainer.py
#### TODO
- 程式不正常結束bug
- data跟超參裡面的參數都做成GUI方便設定,幕後轉成yaml再餵給網路
- 標記的分類全部都是bubble,隨意標幾個去訓練
### Day4
- data跟hyp裡面的參數做成GUI方便設定,幕後轉成yaml再餵給網路
- 使用介面訓練測試,並用之前的標記資料訓練
#### Questions
- 如何解讀訓練結果
- 如何查看detect實際效果 runs裡面
#### TODO
- 測試使用覆判介面標記的檔案再轉回去YOLO的訓練效果(套上json轉YOLO訓練)
- 標記的分類全部都是bubble,隨意標幾個去訓練
- 串接回覆判介面
- PFL報告
### Day5
- 標記PFL100張 train500epoch train800epoch
## 0808-0812學習週報
### Day1
- 標記完PFL NG並訓練 約0.75
- 嘗試把結果儲存成txt
python detect.py --weights D:/D1/yolov5/runs/PFL/weights/best.py --source D:/D1/yolov5/PFL/images/val --save-txt --save-conf
### Day2
- 按鍵轉檔
- 存檔並用覆判介面讀取物件偵測結果
#### 流程
標記存到PFL/NG(json)-->
轉檔存到yolov5/PFL/converted(txt)-->
分訓練集/驗證集yolov5/PFL(自動?)-->
訓練-->
辨識結果存到yolov5/runs/PFL/detect(json)-->
覆判介面修正存到PFL/retrain(預定)-->
重新訓練(閉環)
#### 問題
- 資料夾list-->用於不同種類照片分類,標記時就先分類,方便轉檔可以直接計算把檔案放到指定位置
- 主畫面辨識改成yolo?
- 存到10個label canvas刪不了圖形
- PASS/NG必要性?
#### TODO
- retrain callback(顯示在訓練介面上的QtSignal)
- PASS/NG功能丟回retrain
- 覆判介面修正label存到PFL/retrain
### Day3
- 討論報告內容
- 確認pass/ng功能
- 辨識完改檔名
- 辨識完覆判介面顯示覆判修正自動跳出訓練訓練完更新模型 回到辨識
#### TODO
- pass ng按下去改檔名存檔retrain
- 主頁面訓練流程(開行程等圖片辨識)
- 每次訓練完新存一個pt
- 拖拉接覆判
### Day4
- pass ng 改檔名存檔加入訓練資料夾
- 連接主畫面(可開始執行但還沒改預測的檔案)
- 每次訓練完新存一個pt
#### TODO
- relabel 刪除類別更新dict,之後可以選擇畫面上的去刪除
- 拖拉接覆判
- 主頁面流程(拖拉檔案辨識接覆判介面\object_detection\yolov5\predict.py)
- 銜接資料管理(標記後Retrain)
### Day5
- relabel 刪除類別更新dict,之後可以選擇畫面上的去刪除
- 拖拉檔案辨識存結果
#### TODO
- 拖拉接覆判 主應用judge函式
- 銜接資料管理(標記後Retrain)
- 結業報告
## 0815-0819學習週報
### Day1
- 拖拉接覆判
- 銜接資料管理
#### TODO
- 銜接資料管理
- retrain
- 結業報告
DataSet跟TrainSet個別分image和labels,因為資料被清掉了所以要重轉txt去分
image跟json放在一起還要分??
### Day2
- 銜接資料管理
- pass/ng /儲存-->確定 功能修正
- 預測/訓練多種class的情況
#### TODO
- auto retrain
- emit 訊號
### Day3
- 修移動圖形bug
- 找到是App多存一張圖
#### 找不到CUDA:
用cmd打開
C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi.exe執行確認正在使用的程序
再用工作管理員結束不正常程序
#### TODO
- 存json改到yoloApp,predict把資料傳出去
- auto retrain
- emit 訊號
### Day4
- add train data 問題
- 存json改到yoloApp,predict把資料傳出去
- auto retrain
- emit 訊號
- 週報
#### TODO
- 更新model
- 資料管理(統計)
#### Questions
- 什麼時候開始retrain? 一整批確認完畢?
### Day5
- 資料管理(統計)
- pass ng 功能修正(不要每次確認都retrain)
- Defect訓練
#### TODO
~~- log info?~~
~~- only show ng~~
~~- 更新model~~
- classtype在trainconfig的介面
## 0822-0826學習週報
### Day1
- 修復刪除cache bug
- classtype在trainconfig的介面
- 結業報告
- train defect(但效果不佳)
#### TODO
- 更新model
- 結業報告
- 校方實習文件
### Day2
- 解決圖片大小問題
- 重新標記train defect
- 解決覆判紀錄不會顯示(儲存問題)
### Day3
- Defect 標記
- Defect train
- 結業報告
#### TODO
- 更新model(參考classify)
### Day4
- 結業報告
- 交接資料
- Defect 標記
- Defect train
#### TODO
- 更新model(參考classify)
### Day5
- 更新model
- 交接文件
#### TODO
- convert改training那邊,從那裡設定trainset 跟dataset路徑
## 0829-0831學習週報
### Day1
- convert改training那邊,從那裡設定trainset 跟dataset路徑
- retrain修正
- T85標記
### Day2
- T85標記
### Day3
- 離職手續
## 校外實習心得報告
<!-- 實習報告內容包含封面至少4頁,以12號字、標楷體繕打,1.5行距。 -->
### 一、實習單位簡介
友達光電股份有限公司(AUO Corporation)前身為達碁科技,與聯友光電合併後更名,營運據點遍布台灣、中國大陸、日本、新加坡、韓國、美國、歐洲等全球各地。擁有製造完備大中小尺寸面板的各世代生產線,而後進軍綠能產業提供客戶高效率太陽能解決方案,提供全方位顯示技術與多元化產品組合、客戶軟硬體系統整合、少量多樣客製化產品及智慧服務。於竹科成立友達科技中心,為臺灣最大光電研發中心,擁有千名以上專業研發工程師,累計全球專利總數逾19200件。
綠能產業提供太陽能解決方案,包含太陽能模組、電廠建置服務以及高度整合的能源管理服務平台。以智慧養老切入,發展軟硬整合的智慧照護新事業,攜手安養中心推出網際網路及智慧照護方案,亦發展出全方位水處理及智能化控制技術提供客戶永續相關解決方案。
將綠色承諾落實於各環節,2015年啟用全台首座自主設計整合之製程用水全回收系統,積極發展廢水全回收技術,主動向政府主管機關提出廢水零排放全回收計畫,年底完成運轉。社會關懷部分善用光電專業積極推廣科普教育。
### 二、實習工作內容概述
在實習單位的先進製造部中,我們需要製作工具供製造部使用,其中包括各種元件以AI檢測瑕疵、自動化閉環管理(以網頁統計及顯示每天判片數量及各類資訊)及偵測異常之自動化控制都屬於檢測工具的範疇。而我這次負責的是AI檢測瑕疵的工具,以物件偵測來判段是否有擦傷、氣泡等瑕疵存在,開發內容包括覆判工具、訓練工具、及串接流程(演算法)。流程依序為:辨識、覆判介面、覆判修正、自動訓練及更新模型。
### 三、實習心得(此部分占本報告總分50%)
https://docs.google.com/document/d/1Agtn8Z4B5SxX8IQjgmaZMxuN62gciKfA/edit?usp=sharing&ouid=108426796947067416593&rtpof=true&sd=true
在本次暑期實習中,在職場中學習到的主要可以分成三大部分:
一、技術能力增長
在之前修習的課程中,我們所學習到的程式技巧就是最基本的邏輯應用而已,不太提到其他的模組如何使用,在這次製作工具的過程中,需要閱讀大量程式碼,這加快了我的閱讀速度跟理解程度,也增進了模組使用的熟練度。實際參與專案製作之後,也了解了更多關於專案管理、除錯工具等等加快抓出錯誤的方法。
二、職場文化觀察
三、個人心態調整
### 四、結論及未來自我期許(此部分占本報告總分30%)
{"metaMigratedAt":"2023-06-17T04:37:26.113Z","metaMigratedFrom":"YAML","title":"AUO學習週報","breaks":true,"description":"By 黃安華 and 陳柏融","contributors":"[{\"id\":\"1256ea94-a5d4-47bb-9b07-a24e315807fd\",\"add\":28111,\"del\":12329},{\"id\":\"ea8c2351-276e-471a-bc62-0e9e4ed5e525\",\"add\":56,\"del\":322}]"}