news 2026/4/22 12:08:34

基于 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/22 17:54:20

轻量级容器环境Colima

Colima是一个在macOS&#xff08;和Linux&#xff09;上运行容器的最小化设置工具&#xff0c;它通过在虚拟机中运行容器&#xff0c;为开发者提供了一个轻量级的本地容器环境。 诞生背景&#xff1a;为什么需要Colima&#xff1f; Colima源于Lima项目&#xff0c;该项目由一群…

作者头像 李华
网站建设 2026/4/19 14:44:36

征程 6 | power management sample

1. 功能概述 本文通过示例演示如何通过相关接口对启动标志进行读写&#xff0c;以及对 main 域电源进行控制与查询。相关 API 定义&#xff0c;请查询 电源管理用户手册 API 部分 。 2. main 域上下电及状态查询示例代码 请参考版本中 Service/Cmd_Utility/power_sample_cmd…

作者头像 李华
网站建设 2026/4/21 11:34:01

网安公司,亏麻了!

又到一年一度的“网安比惨季”。每年这个时候&#xff0c;上市公司一发业绩预告&#xff0c;朋友圈就像开了弹幕&#xff1a;“亏得真稳定”、“一年更比一年凉”、“这行业还有救吗&#xff1f;”我把2025年的成绩单摊开一看&#xff0c;好家伙——这哪是财报&#xff0c;分明…

作者头像 李华
网站建设 2026/4/22 7:49:09

晋升名单其实早就在答辩前定好了?答辩只是走个过场

刚看到个贴子&#xff0c;楼主说自己为了晋升&#xff0c;熬夜做了20页PPT&#xff0c;把一年成绩吹到天上去。结果评委只问了一句&#xff1a;你在项目里的不可替代性是什么&#xff1f;更扎心的是&#xff0c;后来才知道晋升名单早就定好了&#xff0c;答辩纯属走流程。我的看…

作者头像 李华
网站建设 2026/4/17 21:06:26

iPhone17大热,网传有国产手机品牌的旗舰手机最高跌超三成

由于苹果的iPhone17卖得实在太好&#xff0c;一些国产手机品牌总是喜欢对标iPhone17&#xff0c;眼见着在整体销量方面落后太多&#xff0c;于是他们不断缩短时间周期&#xff0c;例如从季度缩短到月份&#xff0c;甚至会时不时拿周销量来证明自己并未必iPhone17差太多&#xf…

作者头像 李华
网站建设 2026/4/18 22:31:53

CANN hixl 在单机多卡场景下的 PCIe 带宽优化策略

相关链接&#xff1a; CANN 组织主页&#xff1a;https://atomgit.com/cannhixl 仓库地址&#xff1a;https://atomgit.com/cann/hixl 前言 在单机多设备&#xff08;Multi-Device&#xff09;AI 训练与推理系统中&#xff0c;设备间的数据交换常通过 PCIe 总线完成。然而&am…

作者头像 李华