# Aidea 自動駕駛比賽 ###### tags: `競賽` ## 比賽介紹 1. **評分標準** + 資格賽:$mIOU$ 分數,公式如下 $$ mIOU = \frac{1}{n-1} \sum_{i \not\in bg} IOU_i = \frac{1}{n-1} \sum_{i \not\in bg} \frac{|Y_i \cap \hat{Y}_i|}{|Y_i \ \cup \hat{Y}_i|} $$ 其中 $n$ 為類別數量,$bg$ 為背景類別 $$ \left\{ \begin{aligned} Y_i &= 所有類別為 \ i \ 的像素\\ \hat{Y}_i & = 所有預測為類別 \ i \ 的像素 \\ \end{aligned} \right. $$ + 決賽:$mIOU$,能耗,速度。 2. **資料** + $35500$ 筆 + 解析度: $(720, 1280)$ + $6$ 個類別 3. [**比賽連結**](https://aidea-web.tw/topic/121d8ddd-2557-4f10-b130-2e6520016361?focus=intro) ## 研究動機 1. **藉比賽研究新技術** + **DropBlock** + **Spatial Attention** 2. **醫學影像切割 (國泰醫院)** ![](https://i.imgur.com/GRvB6q5.png =500x200) 3. **Imbalanced Loss (敗血症專案)** + **Dice Loss** + **mIOU loss** + **SSLoss (sensitivity-specificity loss)** ## 研究方法 1. **資料增強** + **資料增強(顏色)**: Color Jitter, Gaussian Noise, Gaussian Blur。 + **資料增強(幾何)**: Random Perspective, Shift, Rotation (label 也要同時轉換)。 + **Kornia**: 以 **Pytorch** 為後端的資料增強套件,支援在 GPU 上做資料增強。 ![](https://i.imgur.com/ByDwQz9.png =500x200) 2. **前處理** + **Normalize** 3. **模型介紹 (Unet)** + **input shape**: $(3, H, W)$, **output shape**: $(n, H, W)$ + **Encoder-Decoder 架構** + **Encoder(左)**: 傳統卷積層,用於提取語意訊息 + **Decoder(右)**: 還原空間訊息 + **Skip-Connection(灰色箭頭)**: 將 **Encoder**, **Decoder** 的特徵作合併。 ![](https://i.imgur.com/pKUuEoK.png =500x300) 4. **技術改進** + **DropBlock**: 對卷積層進行正則化的技術,通常會加在 **convolution block** 間,或 **skip connection** 之前。 ![](https://i.imgur.com/qlfpB8p.png =200x200) + **條件隨機場**: 損失函數中加入 **pair loss**,會讓模型的輸出更加平滑。 ![](https://i.imgur.com/3mFWqcO.png =350x150) + **Spatial Attention**: 學習空間的 **Attention** 使模型專注於重要區域,通常加在 **Encoder**, **Decoder** 之間。 ![](https://i.imgur.com/mUxJNw2.png) 5. **損失函數** + **Cross Entropy** $$ CE(y_i, \hat{y}_i) =\frac{1}{H \cdot W} \sum_{i =1}^{HW} CE(y_i, \hat{y}_i). $$ + **Weighted Cross Entropy** $$ WCE(y_i, \hat{y}_i) =\alpha \sum_{i =1}^{HW} w_{\hat{y}_i} \cdot CE(y_i, \hat{y}_i). $$ + **SSLoss** $$ SSLoss = w * sensitivity + (1-w)*specificity. $$其中 $$ \left\{ \begin{aligned} sensitivity & = & \frac{TP}{TP + FN} \\ specificity & = & \frac{TN}{TN + FP} \end{aligned} \right. $$ + **SoftDice Loss** $$ DiceLoss = 1 - \frac{1}{n-1}\sum_{i \not \in bg} 2 \cdot \frac{|Y_i \cap \hat{Y}_i|}{|Y_i| + |\hat{Y}_i|}. $$ :::info Dice Score 可視為 soft F1-score $$ 2 \cdot \frac{|Y \cap \hat{Y}|}{|Y| + |\hat{Y}|} \approx \frac{2TP}{2TP + FP + FN} = F_1-score $$ ::: + **IOU Loss** $$ IOULoss = 1 - \frac{1}{n-1}\sum_{i \not \in bg} \frac{|Y_i \cap \hat{Y}_i|}{|Y_i \cup \hat{Y}_i|}. $$ ## 實驗結果 ![](https://i.imgur.com/wmXi7UR.png) ![](https://i.imgur.com/QoQUfWt.png) ## 後續改進 1. **提高圖片解析度** 3. **待探索新模型** + **SegFormer, PVT** + **DropPath** ## 參考資料 1. https://github.com/JunMa11/SegLoss 2. https://discuss.pytorch.org/t/how-the-pytorch-freeze-network-in-some-layers-only-the-rest-of-the-training/7088/8 3. https://arxiv.org/abs/1505.04597 4. https://distill.pub/2016/deconv-checkerboard/ 5. https://arxiv.org/abs/2006.14822 6. https://arxiv.org/abs/1502.03240 7. https://arxiv.org/abs/2004.03696