<style> .ui-infobar, #doc.markdown-body { max-width: 960px; } </style> # 銀合歡正射影像訓練 ## 資料 ![](https://i.imgur.com/34Jl9o6.jpg) ### 1. 18張屏東區域正射影像 (原始影像為DMC) - 16bit 顏色深度 - 4波段 (Red、Green、Blue、NIR) - EPSG:3826 | 2014年拍攝 | 2020年拍攝 | |:--------------------------------:|:--------------------------------:| | 95161002_140824b_32~0131_hr4.tif | 95161002_201103b_32~0097_hr4.tif | | 95161003_140824b_33~0156_hr4.tif | 95161003_201103b_33~0065_hr4.tif | | 95161004_140912d_34~0323_hr4.tif | 95161004_201102d_34~0294_hr4.tif | | 95161012_140824b_32~0135_hr4.tif | 95161012_201103b_32~0093_hr4.tif | | 95161013_140824b_33~0152_hr4.tif | 95161013_201103b_33~0061_hr4.tif | | 95161014_140824b_34~0167_hr4.tif | 95161014_201103b_34~0036_hr4.tif | | 95161022_140824b_32~0139_hr4.tif | 95161022_201103b_32~0089_hr4.tif | | 95161023_140824b_33~0148_hr4.tif | 95161023_201103b_33~0057_hr4.tif | | 95172092_140912d_32~0195_hr4.tif | 95172092_201102d_32~0173_hr4.tif | ### 2. 銀合歡標記資料 shapefile ![](https://i.imgur.com/1OV7TNv.png) ## 訓練流程 ### 1. 前處理 將原始 tif 檔裁切成 256 x 256 pixel 大小的影像後,檢查裁切後影像是否包含銀合歡。 若銀合歡所占面積大於 75% ,標記為銀合歡(1)。 若銀合歡所占面積小於 25% ,標記為非銀合歡(0)。 銀合歡所占面積介於25%~75%,標記為可能是銀合歡(2)。 <!-- 調整所有樣本的顏色深度後 (16bit -> 8bit) 儲存。 --> 將 `95172092_140912d_32~0195_hr4.tif`、`95172092_201102d_32~0173_hr4.tif` 所裁切的影像作為測試資料,其餘16張做為訓練資料。 訓練資料集切分比例為 train : valid = 8 : 2,其中銀合歡 : 非銀合歡 = 1 : 1。 ```flow st=>start: 開始 e=>end: 結束 read=>operation: 影像讀取 padding=>operation: 邊緣擴充 (以 0 值擴充) slice=>operation: 影像裁切 (256 x 256 pixel) check_mask=>condition: 檢查銀合歡面積 是否大於50% true_label=>inputoutput: 銀合歡影像 false_label=>inputoutput: 非銀合歡影像 down_color=>operation: 降顏色深度 (16bit >> 8bit) export=>operation: 匯出檔案 (原始檔名_裁切後col_裁切後row.tif) st->read->padding->down_color->slice->check_mask check_mask(yes)->true_label check_mask(no)->false_label true_label->export false_label->export export->e ``` ![](https://i.imgur.com/GCeh59l.jpg) ### 2. 模型訓練 > https://github.com/microsoft/Swin-Transformer 以 swin-transformer-v2 訓練銀合歡辨識模型。 共有 **34983** 幅 256 x 256 pixel 的影像,其中: | 資料集 | 銀合歡數量 | 非銀合歡數量 | |:--------------:|:----------:|:------------:| | 訓練集 (train) | 2,797 | 2,797 | | 驗證集 (valid) | 699 | 699 | | 測試集 (test) | 474 | 3,490 | | 無使用 | 0 | 24,027 | ### 3. 模型預測 | | 預測銀合歡 | 預測非銀合歡 | 生產者精度(PA) | |:------------:|:----------:|:------------:|:----------:| | 實際銀合歡 | 250 (6.3%) | 224 (5.7%) | 52.7% | | 實際非銀合歡 | 603 (15.2%) | 2,887 (72.8%) | 82.7% | | 使用者精度(UA) | 29.3% | 92.8% | |