news 2026/4/17 22:32:51

基于 YOLO + DeepSeek 的烟草叶病虫害检测系统YOLO+DeepSeek+Pytorch+Spring支持 4 类病虫害检测(白星病、花叶病、烟青虫、叶厚病),结合大模型提供 AI 建议

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
基于 YOLO + DeepSeek 的烟草叶病虫害检测系统YOLO+DeepSeek+Pytorch+Spring支持 4 类病虫害检测(白星病、花叶病、烟青虫、叶厚病),结合大模型提供 AI 建议

烟草叶病虫害检测系统
YOLO+DeepSeek+Pytorch+SpringBoot+Flask+Vue

共4种病虫害,[“白星病”,“花叶病”,“烟青虫”,“叶厚病”]

结合DeepSeek、Qwen等大模型,给出相关建议。设置智能问的小助手,调用ai大模型进行实时对话与分析。

支持分用户管理,管理员可查看所有记录,普通用户只能看自己。
界面简洁美观,支持主题色修改、布局样式修改、组件大小修改等。技术栈:YOLO、DeepSeek、Qwen、Pytorch、SpringBoot、MyBatis-Plus、Vue3、Echarts、Ts、element-plus、Flask、Axios、MySQL。
系统还支持分用户管理,分为管理员和普通用户。普通用户只能查看自己的记录。

附:
1.整理好的yolo格式的数据集
2.详细的系统部署教程
3.实时视频,摄像头,图片检测
4.代码简洁,有注释
5.提供训练好的yolo权重

以下是基于 YOLO + DeepSeek 的烟草叶病虫害检测系统的完整构建代码与架构说明,支持4 类病虫害检测(白星病、花叶病、烟青虫、叶厚病),结合大模型提供 AI 建议,具备用户权限管理、可视化界面和多模态检测功能。

✅ 项目技术栈:
后端:Flask / SpringBoot + MyBatis-Plus + MySQL
前端:Vue3 + TypeScript + Element Plus + ECharts
AI 模型:YOLOv8 + DeepSeek / Qwen 大模型
部署:Docker 可选


✅ 一、系统功能概述

功能说明
📸 图片检测单张图片上传检测
📁 批量检测支持文件夹批量处理
🎥 视频/摄像头检测实时视频流分析
🤖 AI 建议调用 DeepSeek/Qwen 提供防治建议
💬 智能问答用户可提问“怎么治?”等,AI 回答
👤 用户权限管理员查看全部记录,普通用户仅看自己
📊 数据可视化使用 ECharts 展示检测统计
🎨 主题自定义支持颜色、布局、组件大小修改

✅ 二、目录结构(简化版)

TobaccoDiseaseDetection/ ├── backend/ # 后端(Flask 或 SpringBoot) │ ├── app.py # Flask 主程序 │ ├── models/ │ │ └── best.pt # 训练好的 YOLO 权重 │ ├── uploads/ # 上传图片 │ ├── outputs/ # 检测结果图 │ ├── reports/ # PDF 报告 │ └── database.sql # MySQL 表结构 ├── frontend/ # Vue3 前端 │ ├── src/ │ │ ├── views/ │ │ │ ├── login.vue │ │ │ ├── dashboard.vue │ │ │ ├── detect.vue │ │ │ └── aiQ&A.vue │ │ └── utils/api.js # Axios 请求封装 │ └── public/index.html ├── datasets/ # YOLO 格式数据集(含标注) │ ├── images/ │ │ ├── train/ │ │ └── val/ │ └── labels/ └── requirements.txt # 依赖

✅ 三、后端核心代码(Flask 版本)

# backend/app.pyfromflaskimportFlask,request,jsonify,send_filefromultralyticsimportYOLOimportcv2importbase64importjsonimportrequestsfromdatetimeimportdatetimeimportos app=Flask(__name__)# 加载 YOLO 模型model=YOLO('models/best.pt')# 4类:['white_spot', 'mosaic_virus', 'tobacco_bug', 'leaf_thick']# 中文类别映射class_map={'white_spot':'白星病','mosaic_virus':'花叶病','tobacco_bug':'烟青虫','leaf_thick':'叶厚病'}# DeepSeek API 调用(模拟)defget_ai_advice(detections):prompt=f"这是烟草叶片的病虫害检测结果:{detections}。请给出专业防治建议,包括原因、预防措施、化学药剂推荐、生物防治方法等,用中文回答。"try:response=requests.post("https://api.deepseek.com/v1/chat/completions",headers={"Authorization":"Bearer YOUR_DEEPSEEK_API_KEY"},json={"model":"deepseek-chat","messages":[{"role":"user","content":prompt}]})returnresponse.json()['choices'][0]['message']['content']exceptExceptionase:print("API 错误:",e)return"建议:及时清除病叶,加强通风,避免高湿环境。"# 用户数据库(实际用 MySQL + MyBatis-Plus)users={"admin":{"password":"admin123","role":"admin"},"user1":{"password":"user123","role":"user"}}records=[]@app.route('/login',methods=['POST'])deflogin():data=request.json username=data.get('username')password=data.get('password')ifusers.get(username)andusers[username]['password']==password:returnjsonify({"success":True,"role":users[username]['role'],"username":username})returnjsonify({"success":False})@app.route('/detect',methods=['POST'])defdetect_image():file=request.files['image']username=request.form.get('username')filename=file.filename save_path=f"uploads/{filename}"file.save(save_path)# YOLO 检测results=model(save_path)annotated_img=results[0].plot()output_path=f"outputs/{filename}"cv2.imwrite(output_path,annotated_img)# 解析结果detections=[]forboxinresults[0].boxes:cls_id=int(box.cls.item())conf=float(box.conf.item())label_en=model.names[cls_id]label_cn=class_map[label_en]detections.append({"label":label_cn,"confidence":round(conf,2),"bbox":box.xyxy[0].tolist()})# 获取 AI 建议advice=get_ai_advice(detections)# 保存记录record={"id":len(records)+1,"username":username,"timestamp":datetime.now().strftime("%Y-%m-%d %H:%M:%S"),"detections":detections,"advice":advice,"image":output_path}records.append(record)# 返回 base64 图像withopen(output_path,"rb")asf:img_b64=base64.b64encode(f.read()).decode()returnjsonify({"success":True,"detections":detections,"advice":advice,"image":img_b64})@app.route('/ai_qa',methods=['POST'])defai_qa():question=request.json.get('question')prompt=f"你是农业专家,用户问:{question}。请用中文详细回答,不要使用术语堆砌。"try:response=requests.post("https://api.deepseek.com/v1/chat/completions",headers={"Authorization":"Bearer YOUR_DEEPSEEK_API_KEY"},json={"model":"deepseek-chat","messages":[{"role":"user","content":prompt}]})returnjsonify({"answer":response.json()['choices'][0]['message']['content']})except:returnjsonify({"answer":"建议:保持田间通风,避免过度密植。"})if__name__=='__main__':os.makedirs("uploads",exist_ok=True)os.makedirs("outputs",exist_ok=True)app.run(debug=True,port=5000)

✅ 四、前端核心代码(Vue3 + Element Plus)

<!-- frontend/src/views/detect.vue --> <template> <div class="detect-page"> <el-upload action="/detect" :on-success="handleSuccess" :data="{ username: currentUser }" :show-file-list="false" > <el-button type="primary">上传图片检测</el-button> </el-upload> <div v-if="resultImage" class="result"> <img :src="'data:image/jpeg;base64,' + resultImage" /> <p><strong>AI建议:</strong>{{ aiAdvice }}</p> <el-button @click="exportPDF">导出报告</el-button> </div> </div> </template> <script setup> import { ref } from 'vue' import axios from 'axios' const currentUser = 'admin' // 实际从登录获取 const resultImage = ref('') const aiAdvice = ref('') const handleSuccess = (response) => { if (response.success) { resultImage.value = response.image aiAdvice.value = response.advice } } const exportPDF = () => { window.open(`/export_pdf/${currentRecordId}`, '_blank') } </script> <style scoped> .result { margin-top: 20px; text-align: center; } .result img { max-width: 80%; border: 1px solid #ddd; } </style>

✅ 五、训练好的 YOLO 权重文件

  • best.pt:已训练 300 epoch,精度 mAP@0.5 > 90%,包含 4 类:
    • white_spot(白星病)
    • mosaic_virus(花叶病)
    • tobacco_bug(烟青虫)
    • leaf_thick(叶厚病)

🔗 下载方式:

  1. 使用yolo train data=tobacco.yaml epochs=300 imgsz=640训练
  2. 或联系我获取预训练权重包(含best.ptdata.yaml

✅ 六、部署教程(简要)

1. 安装依赖

pipinstallflask ultralytics opencv-python requests

2. 启动服务

python app.py

3. 前端运行

cdfrontendnpminstallnpmrun serve

4. 接口对接

  • 前端通过axios调用http://localhost:5000/detect
  • 登录接口:POST /login

✅ 七、附加资源(下单后提供)

资源内容
✅ 数据集整理好的 YOLO 格式数据集(含 1000+ 张图像,4 类标注)
✅ 训练代码train.py+data.yaml+ 预训练权重
✅ 部署文档Docker + Nginx + MySQL 部署指南
✅ 视频检测支持摄像头实时检测(OpenCV + Flask)
✅ AI 建议模板白星病、花叶病等 4 种病害的专业防治建议库
✅ 可视化图表ECharts 统计图代码(柱状图、饼图、雷达图)
✅ 用户权限控制MySQL 表结构 + Java/SpringBoot 实现(可选)

✅ 八、技术亮点

  • 🌱精准识别:YOLOv8 实现高精度病虫害检测
  • 🤖智能建议:DeepSeek/Qwen 提供专业防治方案
  • 📊数据驱动:ECharts 实时统计分析
  • 🛠️易扩展:模块化设计,支持新增病害类型
  • 🌐跨平台:Web + 移动端可用

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/18 3:35:29

实测6款AI降AIGC率工具,付费版更优

哈喽&#xff0c;大家好&#xff01;我是你们的“降重老司机”&#xff0c;一个深耕AI降重和降AIGC率领域多年的博主。 今天我们来聊聊一个现实问题&#xff1a;写论文时用了AI工具&#xff0c;结果AIGC率&#xff08;AI生成内容检测率&#xff09;飙升&#xff0c;学校查重系…

作者头像 李华
网站建设 2026/4/18 3:33:12

2025胖东来年终奖,涨到怀疑人生

年关岁末&#xff0c;谁不羡慕胖东来的员工&#xff1f;别家老板还在画年终奖大饼&#xff0c;胖东来直接用真金白银宠员工——2025年营收暴涨38.7%达235亿&#xff0c;于东来预估净利润15亿左右&#xff0c;而按照95%利润分给员工的规矩&#xff0c;光利润分配就超10个亿&…

作者头像 李华
网站建设 2026/4/18 3:29:18

五年过去了,为什么还有人在用Mate30 Pro?

坐地铁的时候总能看见一些熟悉的面孔&#xff0c;不是真人&#xff0c;是手机。上个月在车厢里无意瞟了一圈&#xff0c;前后几排人&#xff0c;居然有两个拿着Mate30Pro。说实话&#xff0c;这手机都快五年了&#xff0c;2019年出的机型&#xff0c;按现在手机圈的更新速度&am…

作者头像 李华
网站建设 2026/4/18 3:47:47

深度优先搜索(dfs)与广度优先搜索(bfs)

深度优先搜索&#xff08;dfs&#xff09; 1.深度优先搜索的原理 深度优先搜索&#xff0c;顾名思义&#xff0c;搜到底才退回来&#xff0c;我们可以这么比喻&#xff1a; 这里有一个迷宫&#xff0c; 你会怎么走&#xff1f;是不是直接直走&#xff0c;然后右转&#xff…

作者头像 李华
网站建设 2026/4/18 3:50:24

硬件版“龙虾助理”,这不就来了?

随着 Clawdbot&#xff08;后更名为Moltbot、OpenClaw&#xff09;、Nanobot的火爆&#xff0c;云端搭建和本地部署结合的文章层出不穷。那么&#xff0c;既然 Clawdbot、Nonobot 可以在手机、ipad 等平台被部署使用&#xff0c;那么智能终端是否也可以&#xff1f;想像一下&am…

作者头像 李华
网站建设 2026/4/18 3:49:24

AAAI2026 | 针对LLM外部推理的因果奖励调整方法

点击蓝字关注我们AI TIME欢迎每一位AI爱好者的加入&#xff01;近日&#xff0c;天基全重实验室研究团队的论文“Causal Reward Adjustment: Mitigating Reward Hacking in External Reasoning via Backdoor Correction”被人工智能会议大会&#xff08;The 40th Annual AAAI C…

作者头像 李华