---
# System prepended metadata

title: 2021/04/27 Agricultural project
tags: [Agricultural project]

---

# 2021/04/27 Agricultural project
###### tags: `Agricultural project`

## Leaf detection

### model

yolo_v2

### Data

Trainig: 221
testing: 139

### 目前實驗概況

目前loss最低約為1.97左右

||原圖|預測後圖片|
|--|--|--|
|1|![](https://i.imgur.com/G0MGZHC.jpg =300x400)|![](https://i.imgur.com/OyHRTaF.jpg =300x400)|
|2|![](https://i.imgur.com/xA2YX7o.jpg =300x400)|![](https://i.imgur.com/cVpVIbK.jpg =300x400)|
|3|![](https://i.imgur.com/NuedsK8.jpg =300x400)|![](https://i.imgur.com/BeUmzA4.jpg =300x400)|
|4|![](https://i.imgur.com/q00LoLu.jpg =300x400)|![](https://i.imgur.com/IfeK9zL.jpg =300x400)|
|5|![](https://i.imgur.com/fO0ZoS4.jpg =300x400)|![](https://i.imgur.com/BnHWjos.jpg =300x400)|

上表為目前資料訓練後的預測結果
第一列為最理想之預測結果，第二列右下的box中出現重複的現象，第三與第四列則是將樹幹、草地等其他材質判斷為葉子，第五列為不佳的預測結果

### 問題與解決方法

1.重複框(上表2列) : 加入IOU判斷，若有重複框的狀況則刪除較小者
2.框到其他材質(上表3、4列) : 將樹幹、草地、其他雜草框做負樣本訓練
3.預測不佳(上表5列) : 增加訓練資料並修改訓練參數再做測試

---
## 網頁

撰寫網頁用的mask功能，能將輸入的圖片依照mask去背

|原圖|結果|
|--|--|
|![](https://i.imgur.com/SWVQpXq.jpg)|![](https://i.imgur.com/3gZLW3q.jpg)|

---
## APP
### iOS
#### Step.1 初始頁面
![](https://i.imgur.com/aX01kOE.png)
#### Step.2 按下選取圖片選擇拍照或相簿照片
![](https://i.imgur.com/eve0UpM.png) 
#### Stwp.3 拍攝照片(對準正中間)
![](https://i.imgur.com/c3JmcN5.png)
#### Step.4 自動裁切並顯示辨識結果(固定位置無法調整)
![](https://i.imgur.com/wbIasfO.png)
#### Bouns：左上角選單頁面
![](https://i.imgur.com/QybiZRx.png)
---
### Android
#### Step 1. 初始畫面
![1](https://i.imgur.com/Pc29J1H.jpg =330x)
#### Step 2. 選擇照片
![1-1](https://i.imgur.com/Z2zSLp6.jpg =330x)
#### Step 3. 裁切相片
![](https://i.imgur.com/e9Ar2ni.png)
#### Step 4. 上傳相片至伺服器
![3-1](https://i.imgur.com/seQTxPL.jpg =330x)
#### Step 5. 查看辨識結果
![4](https://i.imgur.com/Ndp4JDu.jpg =330x)
#### 用藥建議
![](https://i.imgur.com/fDhprwA.png)
#### 諮詢專線
![](https://i.imgur.com/QOCDCC5.png)

---
## Plant Pathology 2021
## Dataset
Total 18632 iamges, 12 classes
All original labels in `train.csv` :
| Label                           | Count |
| ------------------------------- | ----- |
| scab                            | 4826  |
| healthy                         | 4626  |
| frog_eye_leaf_spot              | 3181  |
| rust                            | 1860  |
| complex                         | 1602  |
| powdery_mildew                  | 1184  |
| scab frog_eye_leaf_spot         | 686   |
| scab frog_eye_leaf_spot complex | 200   |
| frog_eye_leaf_spot complex      | 165   |
| rust frog_eye_leaf_spot         | 120   |
| rust complex                    | 97    |
| powdery_mildew complex          | 87    |
![](https://i.imgur.com/knT8mMi.png)
### Labels
There are only 4 diseases and ``complex``, ``healthy`` in this dataset.
``complex`` means that the disease is too complicated to be recognized
> Unhealthy leaves with too many diseases to classify visually will have the complex class, and may also have a subset of the diseases identified.


| Label                           | Count |
| ------------------------------- | ----- |
| healthy                         | 4624  |
| scab                            | 5712  |
| frog_eye_leaf_spot              | 4352  |
| complex                         | 2151  |
| rust                            | 2077  |
| powdery_mildew                  | 1271  |

## Experiment
```
training data: 14905
testing data:   3727
epoch:            80
batch_size:       32
```
#### 1. Single-label method + Single-label dataset
* Use Label Powerset to define labels.
* Contain 12 labels in full dataset.
* ACC : 0.8026
#### 2. Multi-label method + Single-label dataset
* Same labels rule as method 1
* Only change model into multi-label mode.
* ACC : 0.8133
#### 3. Multi-label method + Mingle-label dataset
* 6 labels (4 diseases + complex and healthy)
* scab frog_eye_leaf_spot complex is seen to 3 labels.
* ACC : 0.8484
---
## 硬體
與廠商討論需要的設備