|
|
--- |
|
|
license: cc-by-nc-sa-4.0 |
|
|
base_model: |
|
|
- Ultralytics/YOLO11 |
|
|
--- |
|
|
|
|
|
# 水稻病害检测 (with YOLO11L) |
|
|
|
|
|
## 模型简介 |
|
|
|
|
|
- 模型功能:支持多种水稻病害的检测,返回图像中的病害位置(bounding box)以及病害类别(class label)。 |
|
|
|
|
|
- 支持类别:{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'} |
|
|
|
|
|
- 训练数据:3,567张水稻病害图像及对应标注信息([Rice Leaf Spot Disease Annotated Dataset](https://www.kaggle.com/datasets/hadiurrahmannabil/rice-leaf-spot-disease-annotated-dataset)),训练200epoch。 |
|
|
- 评测指标:测试集 {mAP50: 56.3, mAP50-95: 34.9} |
|
|
|
|
|
|
|
|
|
|
|
## 模型使用(with Data-Juicer) |
|
|
|
|
|
- 输出格式: |
|
|
|
|
|
``` |
|
|
[{ |
|
|
"images": image_path1, |
|
|
"objects": { |
|
|
"ref": [class_label1, class_label2, ...], |
|
|
"bbox": [bbox1, bbox2, ...] |
|
|
} |
|
|
}, |
|
|
... |
|
|
] |
|
|
``` |
|
|
|
|
|
- 可参考代码: |
|
|
|
|
|
```python |
|
|
import json |
|
|
from data_juicer.core.data import NestedDataset as Dataset |
|
|
from data_juicer.ops.mapper.image_detection_yolo_mapper import ImageDetectionYoloMapper |
|
|
from data_juicer.utils.constant import Fields, MetaKeys |
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
|
|
image_path1 = "test1.jpg" |
|
|
image_path2 = "test2.jpg" |
|
|
image_path3 = "test3.jpg" |
|
|
|
|
|
source_list = [{ |
|
|
'images': [image_path1, image_path2, image_path3] |
|
|
}] |
|
|
|
|
|
class_names =['水稻白叶枯病Bacterial_Leaf_Blight', '水稻胡麻斑病Brown_Spot', '健康水稻HealthyLeaf', '稻瘟病Leaf_Blast', '水稻叶鞘腐病Leaf_Scald', '水稻窄褐斑病Narrow_Brown_Leaf_Spot', '水稻穗颈瘟Neck_Blast', '稻飞虱Rice_Hispa'] |
|
|
|
|
|
op = ImageDetectionYoloMapper( |
|
|
imgsz=640, conf=0.05, iou=0.5, model_path='Path_to_YOLO11L-Rice-Disease-Detection.pt') |
|
|
|
|
|
|
|
|
dataset = Dataset.from_list(source_list) |
|
|
if Fields.meta not in dataset.features: |
|
|
dataset = dataset.add_column(name=Fields.meta, |
|
|
column=[{}] * dataset.num_rows) |
|
|
dataset = dataset.map(op.process, num_proc=1, with_rank=True) |
|
|
res_list = dataset.to_list()[0] |
|
|
|
|
|
new_data = [] |
|
|
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__"]): |
|
|
temp_json = {} |
|
|
temp_json["images"] = temp_image_name |
|
|
temp_json["objects"] = {"ref": [], "bbox":temp_bbox_lists} |
|
|
|
|
|
for temp_object_label in class_name_lists: |
|
|
temp_json["objects"]["ref"].append(class_names[int(temp_object_label)]) |
|
|
|
|
|
new_data.append(temp_json) |
|
|
|
|
|
with open("./output.json", "w") as f: |
|
|
json.dump(new_data, f) |
|
|
``` |