当前位置: 首页 > news >正文

植物叶片病害检测数据集 5100张 29类 带标注 voc yolo

 植物叶片病害检测数据集 5100张 29类 带标注 voc yolo

植物叶片病害检测数据集

名称

植物叶片病害检测数据集 (Plant Leaf Disease Detection Dataset)

规模

  • 图像数量:5154张图像。
  • 类别:29种病害类型。
  • 分类名: (图片张数,标注个数)
    Tomato leaf bacterial spot: (157. 424)
    Potato leaf early blight: (164. 477)
    Bell_ pepper leaf spot: (89. 362)
    Strawberry leaf: (132. 674)
    grape leaf black rot: (261. 467)
    grape leaf: (83, 277)
    Tomato leaf: (120, 600)
    Bell pepper leaf: (72. 409)
    Potato leaf: (4, 18)
    Peach leaf: (156, 899)
    Corn leaf blight: (284, 543)
    Apple rust leaf: (355, 721)
    Cherry leaf: (73. 298)
    Tomato Early blight leaf: (360, 862)
    Apple Scab Leaf: (371, 627)
    Tomato leaf yellow virus: (100, 1095)
    Corn Gray leaf spot :
    (259, 304)
    Corn rust leaf: (477. 516)
    Soyabean leaf: (80, 314)
    Raspberry leaf: (173, 811)
    Blueberry leaf: (153. 1106)
    Squash Powdery mi Idew leaf: (180, 338)
    Tomato mold leaf: (116, 386)
    Tomato leaf late blight: (462. 925)
    Tomato Septoria leaf spot :
    196, 549)
    Tomato leaf mosaic virus: (82, 382)
    Potato leaf late blight: (137. 324)
    Apple leaf: (117. 320)
    Tomato two spotted spider mites leaf: (9, 9)
    总数:
    (5154, 15037)
    总类(nc)
    29类
     
  • 标注个数:15037个标注。
数据划分

  • 训练集 (Train):通常占总数据的80%左右,约4123张图像。
  • 验证集 (Validation):通常占总数据的20%左右,约1031张图像。
类别和数量
  • Tomato leaf bacterial spot:157张图像,424个标注。
  • Potato leaf early blight:89张图像,362个标注。
  • Bell pepper leaf spot:164张图像,674个标注。
  • Grape leaf black rot:261张图像,467个标注。
  • Strawberry leaf:132张图像,649个标注。
  • ...:其他各类病害对应的图像数量和标注数量。
数据特点
  • 高质量与高分辨率:所有图像均为高分辨率,适合进行详细的目标检测任务。
  • 多样性和复杂性:图像覆盖了多种植物叶片病害类型,增加了模型的泛化能力。
  • 详尽标注:每个图像都附有准确的边界框标注信息,确保了训练数据的质量。
应用领域
  • 农业监测:帮助农民及时发现并治疗作物病害,减少农作物损失。
  • 智能农业:结合无人机或机器人技术实现自动化病害检测和防治。
  • 科研应用:为植物病理学和农业科学研究提供数据支持。
1. 安装依赖库

首先,确保安装了必要的依赖库。可以在项目目录中的requirements.txt文件中列出这些依赖库,然后运行以下命令进行安装:

pip install -r requirements.txt

requirements.txt 文件内容示例:

torch==1.10.0
torchvision==0.11.1
pandas==1.3.4
cv2
albumentations==1.1.0
2. 创建数据集

定义一个自定义的数据集类,并创建数据加载器。

import os
import pandas as pd
import cv2
from torch.utils.data import Dataset, DataLoader
from torchvision.transforms import Compose, ToTensor, Normalize, Resize
from albumentations import HorizontalFlip, RandomBrightnessContrast, ShiftScaleRotate, BboxFromMasks, BBoxFormatPASCAL
from albumentations.pytorch import ToTensorV2

# 自定义数据集类
class PlantDiseaseDataset(Dataset):
    def __init__(self, data_root, annotations_file, transforms=None):
        self.data_root = data_root
        self.annotations = pd.read_csv(annotations_file)
        self.transforms = transforms

    def __len__(self):
        return len(self.annotations)

    def __getitem__(1, idx):
        img_path = os.path.join(self.data_root, self.annotations.iloc[idx, 0])
        image = cv2.imread(img_path)
        bboxes = self.annotations.iloc[idx, 1:].values.reshape(-1, 4)  # bounding box coordinates
        labels = self.annotations.columns[1:]

        if self.transforms:
            augmented = self.transforms(image=image, bboxes=bboxes)
            image = augmented['image']
            bboxes = augmented['bboxes']

        return image, bboxes, labels

# 图像预处理
def get_transforms():
    """构建预处理函数"""
    _transform = [
        Resize(height=416, width=416, interpolation=cv2.INTER_LINEAR),
        HorizontalFlip(p=0.5),
        RandomBrightnessContrast(p=0.2),
        ShiftScaleRotate(p=0.5, shift_limit=0.0625, scale_limit=0.2, rotate_limit=15),
        Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
        ToTensorV2(),
        BboxFromMasks(format=BBoxFormatPASCAL)
    ]
    return Compose(_transform)

# 创建数据加载器
train_dataset = PlantDiseaseDataset(
    data_root='path_to_your_data_directory',
    annotations_file='path_to_your_annotations.csv',
    transforms=get_transforms()
)
val_dataset = PlantDiseaseDataset(
    data_root='path_to_your_data_directory',
    annotations_file='path_to_your_annotations.csv',
    transforms=get_transforms()
)

train_loader = DataLoader(train_dataset, batch_size=32, shuffle=True, num_workers=4)
val_loader = DataLoader(val_dataset, batch_size=32, shuffle=False, num_workers=4)
3. 训练YOLOv5模型

使用YOLOv5进行训练。

!git clone https://github.com/ultralytics/yolov5  # 下载YOLOv5代码仓库
cd yolov5

# 使用YOLOv5训练模型
python train.py --weights yolov5s.pt --data path_to_your_data.yaml --name plant_disease_detection --img 416 --batch 16 --epochs 100 --device 0
  • 数据配置文件:创建一个名为data.yaml的数据配置文件,其中包含训练和验证数据集的信息。
train: path_to_your_train_images
val: path_to_your_val_images
nc: 29  # 类别数量
names: [Tomato leaf bacterial spot, Potato leaf early blight, Bell pepper leaf spot, Grape leaf black rot, Strawberry leaf, ...]
4. 调整模型
  • 超参数调整:根据实际情况调整模型的超参数,例如学习率、批大小等。
  • 数据增强:增加数据增强策略,如旋转、缩放

相关文章:

  • MQTT.fx 1.7.1使用说明篇(OneNET-MQTT-API调试)
  • SpringMVC源码-AbstractUrlHandlerMapping处理器映射器将实现Controller接口的方式定义的路径存储进去
  • 车辆重识别(2020NIPS去噪扩散概率模型)论文阅读2024/9/27
  • 560. 和为 K 的子数组
  • 论文阅读(十一):CBAM: Convolutional Block Attention Module
  • 人工智能发展历程
  • 云原生数据库 PolarDB
  • 容器编排工具Docker Compose
  • 网站建设中常见的网站后台开发语言有哪几种,各自优缺点都是什么?
  • Stable Diffusion绘画 | SDXL模型使用注意事项
  • dockerhub 镜像拉取超时的解决方法
  • Java中的HTTP请求:使用Apache HttpClient
  • kotlin中的对象表达式与java中的匿名内部类
  • 基于小程序+Vue + Spring Boot的进销存库存出库入库统计分析管理系统
  • APISIX 联动雷池 WAF 实现 Web 安全防护
  • WebRTC入门
  • Glide基本用法及With方法源码解析
  • ES索引备份
  • AT89s51单片机和STC单片机烧录不同引脚问题
  • ICM20948 DMP代码详解(53)
  • 看展览|2025影像上海艺博会:市场与当代媒介中的摄影
  • 七方面118项任务,2025年知识产权强国建设推进计划印发
  • 【社论】以法治力量促进民企长远健康发展
  • 国家发改委副主任谈民营经济促进法:以法治的稳定性增强发展的确定性
  • 全球第七个迪士尼主题公园将落户阿布扎比
  • 多地跟进官宣下调公积金贷款利率,最低降至2.1%