Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,80 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
base_model:
|
| 4 |
+
- Ultralytics/YOLO11
|
| 5 |
---
|
| 6 |
+
|
| 7 |
+
# 水稻病害检测 (with YOLO11L)
|
| 8 |
+
|
| 9 |
+
## 模型简介
|
| 10 |
+
|
| 11 |
+
- 模型功能:支持多种水稻病害的检测,返回图像中的病害位置(bounding box)以及病害类别(class label)。
|
| 12 |
+
|
| 13 |
+
- 支持类别:{0: '水稻白叶枯病Bacterial_Leaf_Blight', 1: '水稻胡麻斑病Brown_Spot', 2: '健康水稻HealthyLeaf', 3: '稻瘟病Leaf_Blast', 4: '水稻叶鞘腐病Leaf_Scald', 5: '水稻窄褐斑病Narrow_Brown_Leaf_Spot', 6: '水稻穗颈瘟Neck_Blast', 7: '稻飞虱Rice_Hispa'}
|
| 14 |
+
|
| 15 |
+
- 训练数据:3,567张水稻病害图像及对应标注信息([Rice Leaf Spot Disease Annotated Dataset](https://www.kaggle.com/datasets/hadiurrahmannabil/rice-leaf-spot-disease-annotated-dataset)),训练200epoch。
|
| 16 |
+
- 评测指标:测试集 {mAP50: 56.3, mAP50-95: 34.9}
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
## 模型使用(with Data-Juicer)
|
| 21 |
+
|
| 22 |
+
- 输出格式:
|
| 23 |
+
|
| 24 |
+
```
|
| 25 |
+
[{
|
| 26 |
+
"images": image_path1,
|
| 27 |
+
"objects": {
|
| 28 |
+
"ref": [class_label1, class_label2, ...],
|
| 29 |
+
"bbox": [bbox1, bbox2, ...]
|
| 30 |
+
}
|
| 31 |
+
},
|
| 32 |
+
...
|
| 33 |
+
]
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
- 可参考代码:
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
import json
|
| 40 |
+
from data_juicer.core.data import NestedDataset as Dataset
|
| 41 |
+
from data_juicer.ops.mapper.image_detection_yolo_mapper import ImageDetectionYoloMapper
|
| 42 |
+
from data_juicer.utils.constant import Fields, MetaKeys
|
| 43 |
+
|
| 44 |
+
if __name__ == "__main__":
|
| 45 |
+
|
| 46 |
+
image_path1 = "test1.jpg"
|
| 47 |
+
image_path2 = "test2.jpg"
|
| 48 |
+
image_path3 = "test3.jpg"
|
| 49 |
+
|
| 50 |
+
source_list = [{
|
| 51 |
+
'images': [image_path1, image_path2, image_path3]
|
| 52 |
+
}]
|
| 53 |
+
|
| 54 |
+
class_names =['水稻白叶枯病Bacterial_Leaf_Blight', '水稻胡麻斑病Brown_Spot', '健康水稻HealthyLeaf', '稻瘟病Leaf_Blast', '水稻叶鞘腐病Leaf_Scald', '水稻窄褐斑病Narrow_Brown_Leaf_Spot', '水稻穗颈瘟Neck_Blast', '稻飞虱Rice_Hispa']
|
| 55 |
+
|
| 56 |
+
op = ImageDetectionYoloMapper(
|
| 57 |
+
imgsz=640, conf=0.05, iou=0.5, model_path='Path_to_YOLO11L-Rice-Disease-Detection.pt')
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
dataset = Dataset.from_list(source_list)
|
| 61 |
+
if Fields.meta not in dataset.features:
|
| 62 |
+
dataset = dataset.add_column(name=Fields.meta,
|
| 63 |
+
column=[{}] * dataset.num_rows)
|
| 64 |
+
dataset = dataset.map(op.process, num_proc=1, with_rank=True)
|
| 65 |
+
res_list = dataset.to_list()[0]
|
| 66 |
+
|
| 67 |
+
new_data = []
|
| 68 |
+
for temp_image_name, temp_bbox_lists, class_name_lists in zip(res_list["images"], res_list["__dj__meta__"]["__dj__bbox__"], res_list["__dj__meta__"]["__dj__class_label__"]):
|
| 69 |
+
temp_json = {}
|
| 70 |
+
temp_json["images"] = temp_image_name
|
| 71 |
+
temp_json["objects"] = {"ref": [], "bbox":temp_bbox_lists}
|
| 72 |
+
|
| 73 |
+
for temp_object_label in class_name_lists:
|
| 74 |
+
temp_json["objects"]["ref"].append(class_names[int(temp_object_label)])
|
| 75 |
+
|
| 76 |
+
new_data.append(temp_json)
|
| 77 |
+
|
| 78 |
+
with open("./output.json", "w") as f:
|
| 79 |
+
json.dump(new_data, f)
|
| 80 |
+
```
|