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

植物叶片病害检测数据集 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. 调整模型
  • 超参数调整:根据实际情况调整模型的超参数,例如学习率、批大小等。
  • 数据增强:增加数据增强策略,如旋转、缩放

http://www.kler.cn/news/334498.html

相关文章:

  • 利用 Python 爬虫采集 1688商品详情
  • 【D3.js in Action 3 精译_028】3.4 小节 DIY 实战:使用 Observable 在线绘制 D3 条形图
  • 问:TCP长连接vs短连接有哪些差异?
  • Unity MVC框架演示 1-1 理论分析
  • VSCode python代码颜色调整与pycharm对齐
  • 项目-坦克大战笔记-墙体销毁以及人机销毁
  • vue-live2d看板娘集成方案设计使用教程
  • sqlalchemy 加速数据库操作
  • Uniapp API
  • 李飞飞谈AI+3D发展:3D/4D AI将成为下一个重要前沿
  • NVIDIA网卡系列之ConnectX-4规格信息(50G-PCIe 3.0x8-8PF256VF-2015年发布)
  • yolov8/9/10模型在安全帽、安全衣检测中的应用【代码+数据集+python环境+GUI系统】
  • RCE_绕过综合
  • chatGPT对我学术写作的三种帮助
  • 使用Conda管理python环境的指南
  • 毕业设计_基于springboot+layui+mybatisPlus的中小型仓库物流管理系统源码+SQL+教程+可运行】41004
  • .NET 一款支持天蝎的免杀WebShell
  • 聊天记录怎么监控?企业微信聊天记录监控的2个方法分享!员工权益vs企业管理
  • Java应用程序的服务器有哪些?
  • LeetCode78 子集