File size: 2,803 Bytes
bbab4a8
 
 
 
 
e2403b7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
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)
```