基于yolov11+django+deepseek的农业植物叶子病害农作物病虫害检测系统带登录界面python源码+onnx模型+精美web界面

作品简介

效果展示

登录界面

主界面

基于 YOLO11 的目标检测系统,支持图片、视频和实时摄像头检测,集成 DeepSeek AI 分析功能。

功能特性

  • 图片目标检测
  • 视频文件检测
  • 实时摄像头检测
  • DeepSeek AI 智能分析
  • 可调节的检测参数(置信度、IoU)
  • 美观的用户界面

【测试环境】

windows10 anaconda3+python3.10 torch 2.3.1 ultralytics 8.4.7 Django==5.2.11

【模型可以检测出41类别】

[‘appleblackrot’, ‘apple healthy’, ‘apple scab’, ‘bell pepper bacterial spot’, ‘bell pepper healthy’, ‘cassava Brown Streak Disease’, ‘cassava bacterial blight’, ‘cassava green mottle’, ‘cedar applerust’, ‘cherry healthy’, ‘cherry powdery mildew’, ‘corn cerespora leaf spot’, ‘corn common rust’, ‘corn healthy’, ‘grape black rot’, ‘grape esca’, ‘grape healthy’, ‘grape leaf blight’, ‘healthy cassava’, ‘mosaic cassava’, ‘northern leaf blight’, ‘orange citrus greening’, ‘peach bacterial spot’, ‘peach healthy’, ‘potato early blight’, ‘potato healthy’, ‘potato late blight’, ‘rice brown spot’, ‘rice healthy’, ‘rice hispa’, ‘rice leaf blast’, ‘spider mites two-spotted spider mite’, ‘squash powdery mildew’, ‘strawberry healthy’, ‘strawberry leaf scorch’, ‘tomato bacterial spot’, ‘tomato early blight’, ‘tomato late blight’, ‘tomato leaf healthy’, ‘tomato leaf mould’, ‘tomato septoria leaf spot’]

【训练数据集介绍】

数据集格式:YOLO格式(不包含分割路径的txt文件,仅仅包含jpg图片以及对应的yolo格式txt文件)

图片数量(jpg文件个数):33085

标注数量(txt文件个数):33085

训练集数量:30105

验证集数量:1988

测试集数量:992

标注类别数:41

所在github仓库:firc-dataset

标注类别名称(注意yolo格式类别顺序不和这个对应,而以labels文件夹classes.txt为准):['apple black rot','apple healthy','apple scab','bell pepper bacterial spot','bell pepper healthy','cassava Brown Streak Disease','cassava bacterial blight','cassava green mottle','cedar apple rust','cherry healthy','cherry powdery mildew','corn cerespora leaf spot','corn common rust','corn healthy','grape black rot','grape esca','grape healthy','grape leaf blight','healthy cassava','mosaic cassava','northern leaf blight','orange citrus greening','peach bacterial spot','peach healthy','potato early blight','potato healthy','potato late blight','rice brown spot','rice healthy','rice hispa','rice leaf blast','spider mites two-spotted spider mite','squash powdery mildew','strawberry healthy','strawberry leaf scorch','tomato bacterial spot','tomato early blight','tomato late blight','tomato leaf healthy','tomato leaf mould','tomato septoria leaf spot']

每个类别标注的框数:

apple black rot(苹果黑腐病)框数 = 807

apple healthy(健康苹果)框数 = 847

apple scab(苹果疮痂病)框数 = 842

bell pepper bacterial spot(甜椒细菌性叶斑病)框数 = 837

bell pepper healthy(健康甜椒)框数 = 838

cassava Brown Streak Disease(木薯褐色条纹病)框数 = 2472

cassava bacterial blight(木薯细菌性枯萎病)框数 = 1330

cassava green mottle(木薯绿色斑驳病)框数 = 2643

cedar apple rust(苹果锈病)框数 = 646

cherry healthy(健康樱桃)框数 = 830

cherry powdery mildew(樱桃白粉病)框数 = 844

corn cerespora leaf spot(玉米尾孢叶斑病)框数 = 848

corn common rust(玉米普通锈病)框数 = 849

corn healthy(健康玉米)框数 = 849

grape black rot(葡萄黑腐病)框数 = 836

grape esca(葡萄癌肿病)框数 = 822

grape healthy(健康葡萄)框数 = 833

grape leaf blight(葡萄叶枯病)框数 = 835

healthy cassava(健康木薯)框数 = 1303

mosaic cassava(木薯花叶病)框数 = 7156

northern leaf blight(玉米大斑病)框数 = 869

orange citrus greening(柑橘黄龙病)框数 = 824

peach bacterial spot(桃细菌性叶斑病)框数 = 835

peach healthy(健康桃)框数 = 836

potato early blight(马铃薯早疫病)框数 = 840

potato healthy(健康马铃薯)框数 = 363

potato late blight(马铃薯晚疫病)框数 = 834

rice brown spot(水稻褐斑病)框数 = 851

rice healthy(健康水稻)框数 = 799

rice hispa(水稻铁甲虫)框数 = 789

rice leaf blast(水稻叶瘟病)框数 = 830

spider mites two-spotted spider mite(二斑叶螨)框数 = 652

squash powdery mildew(南瓜白粉病)框数 = 937

strawberry healthy(健康草莓)框数 = 825

strawberry leaf scorch(草莓叶枯病)框数 = 920

tomato bacterial spot(番茄细菌性叶斑病)框数 = 821

tomato early blight(番茄早疫病)框数 = 863

tomato late blight(番茄晚疫病)框数 = 941

tomato leaf healthy(健康番茄叶)框数 = 826

tomato leaf mould(番茄叶霉病)框数 = 842

tomato septoria leaf spot(番茄斑枯病)框数 = 848

总框数=44412

使用标注工具:labelImg

标注规则:对类别进行画矩形框

重要说明:暂无

特别声明:本数据集不对训练的模型或者权重文件精度作任何保证

图片预览:





标注例子:



【训练信息】

训练集图片数=30223

验证集图片数=2001

训练map=92.1%

训练精度(Precision)=91.1%

训练召回率(Recall)=90.4%

【验证集精度】

类别=Map50(%)

MAP50

all=92

apple black rot=100

apple healthy=99

apple scab=100

bell pepper bacterial spot=100

bell pepper healthy=100

cassava Brown Streak Disease=53

cassava bacterial blight=45

cassava green mottle=58

cedar apple rust=100

cherry healthy=100

cherry powdery mildew=100

corn cerespora leaf spot=97

corn common rust=100

corn healthy=100

grape black rot=100

grape esca=100

grape healthy=100

grape leaf blight=99

healthy cassava=43

mosaic cassava=57

northern leaf blight=96

orange citrus greening=100

peach bacterial spot=100

peach healthy=99

potato early blight=100

potato healthy=100

potato late blight=100

rice brown spot=98

rice healthy=76

rice hispa=85

rice leaf blast=93

spider mites two-spotted spider mite=99

squash powdery mildew=98

strawberry healthy=100

strawberry leaf scorch=97

tomato bacterial spot=98

tomato early blight=99

tomato late blight=96

tomato leaf healthy=100

tomato leaf mould=100

tomato septoria leaf spot=100

安装依赖

pip install -r requirements.txt

数据库迁移

python manage.py makemigrations
python manage.py migrate

运行项目

python manage.py runserver

访问 ​http://127.0.0.1:8000​

默认登录信息

  • 用户名: admin
  • 密码: admin

项目主要文件结构

yolo11-django-deepseek-det-system/
├── manage.py                 # Django 管理脚本
├── yolo_detection/           # 项目配置目录
│   ├── __init__.py
│   ├── settings.py          # 项目设置
│   ├── urls.py               # 主 URL 配置
│   └── wsgi.py               # WSGI 配置
├── detection/                # 检测应用
│   ├── __init__.py
│   ├── apps.py               # 应用配置
│   ├── forms.py              # 表单定义
│   ├── models.py             # 数据模型
│   ├── urls.py               # 应用 URL 配置
│   └── views.py              # 视图函数
├── templates/                # 模板目录
├── test_img/                # 测试图片目录
│   ├── index.html            # 主页面
│   └── login.html            # 登录页面
├── static/                   # 静态文件目录
├── media/                    # 媒体文件目录
│   └── uploads/              # 上传文件目录
├── requirements.txt          # 依赖列表
├── weights/                # 模板目录
│   ├── yolov11n.onnx            # 模型文件
│   └── results.png            # 训练日志图片
│   ├── class_names            # 模型类别文件
│   └── 模型说明.txt            # 训练简单介绍和训练过程map0.5参数

技术栈

  • Django 4.2+
  • YOLO11 (Ultralytics)
  • OpenCV
  • DeepSeek API
  • Chart.js
  • HTML5/CSS3/JavaScript

注意事项

  • 确保 ​​yolov11n.onnx​​ 模型文件在项目weights目录
  • DeepSeek API 密钥需要在 ​​settings.py​​ 中配置
  • 建议使用 Python 3.8+

常用评估参数介绍

在目标检测任务中,评估模型的性能是至关重要的。你提到的几个术语是评估模型性能的常用指标。下面是对这些术语的详细解释:

Class: 这通常指的是模型被设计用来检测的目标类别。例如,一个模型可能被训练来检测车辆、行人或动物等不同类别的对象。

Images: 表示验证集中的图片数量。验证集是用来评估模型性能的数据集,与训练集分开,以确保评估结果的公正性。

Instances: 在所有图片中目标对象的总数。这包括了所有类别对象的总和,例如,如果验证集包含100张图片,每张图片平均有5个目标对象,则Instances为500。

P(精确度Precision): 精确度是模型预测为正样本的实例中,真正为正样本的比例。计算公式为:Precision = TP / (TP + FP),其中TP表示真正例(True Positives),FP表示假正例(False Positives)。

R(召回率Recall): 召回率是所有真正的正样本中被模型正确预测为正样本的比例。计算公式为:Recall = TP / (TP + FN),其中FN表示假负例(False Negatives)。

mAP50: 表示在IoU(交并比)阈值为0.5时的平均精度(mean Average Precision)。IoU是衡量预测框和真实框重叠程度的指标。mAP是一个综合指标,考虑了精确度和召回率,用于评估模型在不同召回率水平上的性能。在IoU=0.5时,如果预测框与真实框的重叠程度达到或超过50%,则认为该预测是正确的。

mAP50-95: 表示在IoU从0.5到0.95(间隔0.05)的范围内,模型的平均精度。这是一个更严格的评估标准,要求预测框与真实框的重叠程度更高。在目标检测任务中,更高的IoU阈值意味着模型需要更准确地定位目标对象。mAP50-95的计算考虑了从宽松到严格的多个IoU阈值,因此能够更全面地评估模型的性能。 这些指标共同构成了评估目标检测模型性能的重要框架。通过比较不同模型在这些指标上的表现,可以判断哪个模型在实际应用中可能更有效。

常见问题

目标检测训练中,Mean Average Precision(MAP)偏低可能有以下原因: 原因一:欠拟合:如果训练数据量过小,模型可能无法学习到足够的特征,从而影响预测效果,导致欠拟合,进而使MAP偏低。因此可以加大数据集数量

原因二:小目标:如果数据集包含大部分小目标则一般会有可能产生map偏低情况,因为小目标特征不明显,模型很难学到特征。

原因三:模型调参不对:比如学习率调整过大可能会导致学习能力过快,模型参数调节出现紊乱

原因四:过拟合(现在模型基本不存在这种情况):如果模型在训练数据上表现非常好,但在验证或测试数据上表现较差,可能是出现了过拟合。这通常是因为模型参数过多,而训练数据量相对较小,导致模型学习到了训练数据中的噪声或特定模式,而无法泛化到新的数据。如今现在目标检测模型都对这个情况做的很好,很少有这种情况发生。

原因五:场景不一样:验证集验证精度高,测试集不行,则有可能是与训练模型场景图片不一致导致测试map过低 针对以上原因,可以采取以下措施来提高MAP:

(1)优化模型结构:根据任务和数据集的特点选择合适的模型,并尝试使用不同的网络架构和构件来改进模型性能。

(2)增强数据预处理:对数据进行适当的预处理和增强,如数据归一化、缺失值填充、数据扩增等,以提高模型的泛化能力。

(3)调整损失函数:尝试使用不同的损失函数或组合多种损失函数来优化模型性能。

(4)优化训练策略:调整学习率、批次大小、训练轮数等超参数,以及使用学习率衰减、动量等优化算法来改善模型训练效果。

(5)使用预训练模型:利用在大规模数据集上预训练的模型进行迁移学习,可以加速模型收敛并提高性能。 (6)增加数据集数量

提供的文件

python源码

yolo11n.onnx模型(不提供pytorch模型)

训练的map,P,R曲线图(在weights\results.png)

测试图片(在test_img文件夹下面)

注意提供数据集在数据集地址.xlsx文件中

创作时间: