Skip to content

Dadalia1917/PneumoAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

基于计算机图像分类与大模型反馈的肺炎诊断系统

这是一个结合深度学习图像分类和大模型反馈的智能肺炎诊断系统。系统通过YOLOv8模型进行图像分析,检测肺部X光片或CT图像中的肺炎特征,并利用大型语言模型提供诊断建议和解释。

🏗️ 系统架构

📋 架构概览

graph TD
    %% 前端层
    subgraph Frontend["🖥️ 前端层 (Vue.js)"]
        direction TB
        UI[用户界面]
        UploadPage[图像上传页面]
        DiagnosisPage[诊断结果页面]
        HistoryPage[历史记录页面]
        UserPage[用户管理页面]
        
        UI --- UploadPage
        UI --- DiagnosisPage
        UI --- HistoryPage
        UI --- UserPage
    end

    %% 业务逻辑层
    subgraph Backend["⚙️ 业务逻辑层 (Spring Boot)"]
        direction TB
        subgraph Controllers["控制器层"]
            PredController[预测控制器]
            UserController[用户控制器]
            FileController[文件控制器]
            DiagnosisController[诊断控制器]
        end
        
        subgraph Services["服务层"]
            DiagnosisService[诊断服务]
            UserService[用户服务]
            FileService[文件服务]
            ReportService[报告服务]
        end
        
        subgraph Mappers["数据访问层"]
            UserMapper[用户映射器]
            DiagnosisMapper[诊断记录映射器]
            ImageMapper[图像记录映射器]
        end
        
        Controllers --- Services
        Services --- Mappers
    end

    %% AI推理层
    subgraph AILayer["🤖 AI推理层 (Flask)"]
        direction TB
        FlaskApp[Flask应用]
        
        subgraph ModelEngine["模型引擎"]
            YOLOModel[YOLO模型]
            ImageClassifier[图像分类器]
            FeatureExtractor[特征提取器]
        end
        
        subgraph AIAssistant["AI助手服务"]
            ChatAPI[ChatAPI]
            DeepSeek[DeepSeek API]
            Qwen[Qwen API]
            LocalModels[本地模型服务]
        end
        
        FlaskApp --- ModelEngine
        FlaskApp --- AIAssistant
    end

    %% 数据存储层
    subgraph Storage["💾 数据存储层"]
        direction LR
        MySQL[(MySQL数据库)]
        FileStorage[(文件存储)]
        
        subgraph Tables["数据表"]
            UserTable[用户表]
            DiagnosisTable[诊断记录表]
            ImageTable[图像记录表]
            ModelTable[模型配置表]
        end
        
        MySQL --- Tables
    end

    %% 外部服务
    subgraph External["🌐 外部服务"]
        direction TB
        OnlineAI[在线AI服务]
        LMStudio[本地LM-Studio]
        LANAI[局域网AI服务]
        MedicalDB[医学数据库]
    end

    %% 连接关系
    Frontend -.-> Backend
    Backend -.-> AILayer
    Backend -.-> Storage
    AILayer -.-> External
    AILayer -.-> Storage
    
    %% 样式
    classDef frontendStyle fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
    classDef backendStyle fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
    classDef aiStyle fill:#fce4ec,stroke:#c2185b,stroke-width:2px
    classDef storageStyle fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
    classDef externalStyle fill:#fff3e0,stroke:#f57c00,stroke-width:2px
    
    class Frontend,UI,UploadPage,DiagnosisPage,HistoryPage,UserPage frontendStyle
    class Backend,Controllers,Services,Mappers,PredController,UserController,FileController,DiagnosisController,DiagnosisService,UserService,FileService,ReportService,UserMapper,DiagnosisMapper,ImageMapper backendStyle
    class AILayer,FlaskApp,ModelEngine,AIAssistant,YOLOModel,ImageClassifier,FeatureExtractor,ChatAPI,DeepSeek,Qwen,LocalModels aiStyle
    class Storage,MySQL,FileStorage,Tables,UserTable,DiagnosisTable,ImageTable,ModelTable storageStyle
    class External,OnlineAI,LMStudio,LANAI,MedicalDB externalStyle
Loading

本项目采用前后端分离架构,包含三个主要组件:

  1. 前端(Vue):基于Vue3+TypeScript构建的用户界面,提供图像上传、诊断结果展示和历史记录查询等功能。
  2. 后端(SpringBoot):负责用户管理、数据存储和请求转发的Java服务。
  3. AI模型服务(Flask):运行深度学习模型和大语言模型的Python服务,提供图像分析和智能诊断功能。

🗄️ 数据模型设计

📊 实体关系图

classDiagram
    %% 实体类
    class User {
        +Integer id
        +String username
        +String password
        +String name
        +String email
        +String role
        +Date createTime
    }
    
    class DiagnosisRecord {
        +Integer id
        +String recordId
        +String imagePath
        +String resultPath
        +String diagnosis
        +Double confidence
        +String symptoms
        +String username
        +DateTime diagnosisTime
        +String aiModel
        +String suggestion
        +String severity
    }
    
    class MedicalImage {
        +Integer id
        +String imageId
        +String originalPath
        +String processedPath
        +String imageType
        +String format
        +Integer width
        +Integer height
        +Long fileSize
        +DateTime uploadTime
    }
    
    %% 控制器类
    class PredictionController {
        -DiagnosisService diagnosisService
        -RestTemplate restTemplate
        +predictPneumonia() Result
        +uploadImage() Result
        +getDiagnosisHistory() Result
    }
    
    %% 服务类
    class FlaskAIService {
        -YOLOModel model
        -ChatAPI chatAPI
        +classifyImage() Dict
        +generateDiagnosis() String
        +extractFeatures() Array
        +analyzeXRay() Dict
    }
    
    %% 关系定义
    User "1" --> "*" DiagnosisRecord : creates
    MedicalImage "1" --> "*" DiagnosisRecord : analyzed_in
    
    PredictionController --> FlaskAIService : calls
    FlaskAIService --> MedicalImage : processes
Loading

🔄 系统流程设计

⏱️ 肺炎诊断流程时序图

sequenceDiagram
    participant U as 🧑‍⚕️ 医生
    participant V as 💻 Vue前端
    participant S as ⚙️ Spring Boot
    participant F as 🤖 Flask AI服务
    participant Y as 🎯 YOLO模型
    participant A as 🧠 AI助手
    participant D as 💾 数据库
    
    Note over U,D: 📤 医学图像上传阶段
    U->>V: 1. 上传X光片/CT图像
    V->>S: 2. POST /api/diagnosis/upload
    S->>D: 3. 保存图像信息
    
    Note over U,A: 🔍 AI诊断阶段
    U->>V: 4. 开始诊断分析
    V->>S: 5. POST /api/diagnosis/predict
    S->>F: 6. 转发诊断请求
    F->>Y: 7. 加载模型并分析
    Y-->>F: 8. 返回诊断结果
    
    Note over F,A: 🧠 医学分析阶段
    alt 医生选择AI助手
        F->>A: 9. 发送诊断结果
        A-->>F: 10. 返回医学建议
    end
    
    Note over S,D: 💾 结果保存阶段
    F-->>S: 11. 返回完整结果
    S->>D: 12. 保存诊断记录
    S-->>V: 13. 返回诊断结果
    V-->>U: 14. 展示诊断分析
Loading

主要功能

  • 肺炎X光片图像分析与诊断
  • 肺部CT图像分析与诊断
  • 视频流实时分析
  • 诊断历史记录管理
  • 智能诊断建议生成
  • 用户账户管理

技术栈

  • 前端:Vue 3、TypeScript、Element Plus
  • 后端:SpringBoot 3.5.4 (最新版)、MyBatis-Plus、MySQL
  • AI服务:Flask、YOLOv8、大型语言模型API
  • Java版本:JDK 24 (最新LTS版本)
  • 部署:Docker (可选)

🚀 最新更新

版本升级 (2025年8月)

  • JDK升级:从Java 1.8 升级到 JDK 24,带来以下改进:
    • 更好的垃圾回收性能
    • 增强的安全特性
    • 改进的JVM性能和内存管理
  • Spring Boot升级:从2.3.7升级到3.5.4
    • 支持更多现代化特性
    • 更好的性能和稳定性
    • 增强的安全性
  • 依赖库更新:升级了所有核心依赖到最新稳定版本
  • 警告修复:解决了JDK 24下的所有编译和运行时警告
    • 添加了--sun-misc-unsafe-memory-access=allow参数解决FastJSON2的sun.misc.Unsafe警告
    • 升级FastJSON2到2.0.58版本(最新稳定版)
    • 配置了完整的JVM参数确保在JDK 24下正常运行

快速开始

前提条件

  • JDK 24 (已升级到最新版本,包含性能优化和安全改进)
  • Node.js 16+
  • Python 3.8+
  • MySQL 8.0+
  • CUDA支持的GPU (推荐用于模型推理)
  • LM-Studio (用于本地部署大模型)

JDK 24 兼容性说明

本项目已完全适配JDK 24,所有JVM警告均已解决:

  • sun.misc.Unsafe警告 - 通过--sun-misc-unsafe-memory-access=allow参数解决
  • 模块系统 - 配置了必要的--add-opens参数
  • 动态代理 - 启用了-XX:+EnableDynamicAgentLoading
  • 参数名保留 - 编译器配置了-parameters标志

如需手动运行,请使用以下JVM参数:

--enable-native-access=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED 
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/sun.misc=ALL-UNNAMED
--sun-misc-unsafe-memory-access=allow
-XX:+EnableDynamicAgentLoading

数据库配置

  1. 创建名为ai的数据库
  2. 运行database.sql脚本初始化数据库结构

后端服务启动

  1. 进入springboot目录
  2. 使用Maven构建项目:mvn clean package
  3. 运行生成的jar文件:java -jar target/Kcsj-0.0.1-SNAPSHOT.jar

AI服务启动

  1. 进入flask目录
  2. 安装依赖:pip install -r requirements.txt
  3. 启动Flask服务:python main\(YOLO\).py

前端启动

  1. 进入vue目录
  2. 安装依赖:npm install
  3. 启动开发服务器:npm run dev
  4. 构建生产版本:npm run build

系统访问

默认登录账号

  • 管理员账号:admin
  • 密码:admin123

使用说明

  1. 访问系统前端界面
  2. 使用默认管理员账号登录:admin/admin123
  3. 进入系统后可以进行肺炎影像的检测和诊断:
    • 上传X光片图像进行肺炎检测
    • 上传CT图像进行分析
    • 查看诊断历史记录
  4. 选择合适的大模型进行智能诊断分析和建议生成

大模型部署与使用

本系统支持多种大模型部署方式,用于生成诊断报告和建议:

支持的模型

  • 云端API模型

    • Deepseek-R1
    • Qwen
  • 局域网部署模型

    • Deepseek-R1-LAN
    • Qwen3-LAN
    • Qwen2.5-VL-LAN
    • Qwen2.5-Omni-LAN
    • Gemma3-LAN
  • 本地部署模型

    • Deepseek-R1-Local
    • Qwen3-Local
    • Qwen2.5-VL-Local
    • Qwen2.5-Omni-Local
    • Gemma3-Local

使用LM-Studio进行本地部署

  1. 下载并安装 LM-Studio
  2. 从Hugging Face或其他来源下载所需模型(如Deepseek-R1、Qwen等)
  3. 在LM-Studio中加载模型
  4. 启动本地API服务器(通常在http://localhost:1234)
  5. 在诊断系统的设置中选择对应的"本地"模型选项

思考模式

系统支持开启思考模式(thinkMode),启用后大模型会提供更详细的分析过程和诊断依据,适合教学和研究使用。

系统截图

(此处可以添加系统界面截图)

模型信息

图像分类模型

本系统使用YOLOv8模型对肺炎影像进行分类和检测。预训练模型存储在flask/weights/目录下。

大语言模型

支持多种大语言模型,既可以通过API密钥访问云端模型,也可以通过LM-Studio在本地部署运行。系统会根据选定的模型自动配置请求参数。

许可证

MIT

贡献

欢迎提交问题和贡献代码,请通过创建Issue或Pull Request参与项目开发。

致谢

感谢所有为本项目提供支持和贡献的人员。

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors