Upload README.md
Browse files
README.md
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# Health Vision AI
|
3 |
+
|
4 |
+
The Health Vision AI is a Flask-based web application powered by machine learning models and a large language model (LLM) that assists in predicting various diseases using medical images. The app also allows users to access research papers and case reports related to their predictions and ask questions directly from the LLM regarding any disease.
|
5 |
+
## Project Overview
|
6 |
+
|
7 |
+
The Health Vision AI web application uses machine learning models to classify medical images into different disease categories. It supports three main disease prediction categories:
|
8 |
+
|
9 |
+
- Gastrointestinal Disease
|
10 |
+
- Chest CT Disease
|
11 |
+
- Chest X-ray Disease
|
12 |
+
|
13 |
+
Additionally, users can query a built-in `LLM` for medical advice or information. The app also provides a unique feature where users can access research papers and case reports related to the predicted disease.
|
14 |
+
|
15 |
+
|
16 |
+
## Tech Stack
|
17 |
+
|
18 |
+
- **Backend:** Flask (Python)
|
19 |
+
- **Frontend:** HTML, CSS, JavaScript
|
20 |
+
- **Machine Learning:** TensorFlow, PyTorch, OpenCV, Scikit-learn
|
21 |
+
- **LLM Integration:** Fine-tuned GPT 2 Model (on custom dataset)
|
22 |
+
- **Database:** None (all data is dynamically served)
|
23 |
+
## Features
|
24 |
+
|
25 |
+
- **Medical Image Predictions:**
|
26 |
+
Predict diseases using models trained on Gastrointestinal, Chest CT, and Chest X-ray images.
|
27 |
+
- **LLM-powered Assistant:**
|
28 |
+
Query the assistant about any disease or condition for a text-based answer.
|
29 |
+
- **Research Papers and Case Reports:**
|
30 |
+
Dynamically load related research papers and case reports for the predicted disease.
|
31 |
+
- **Modern UI with Tabbed Navigation:**
|
32 |
+
Clean, user-friendly interface with multiple tabs for disease categories and interactive elements for prediction results.
|
33 |
+
## Architecture
|
34 |
+
|
35 |
+
The project follows a **Model-View-Controller (MVC)** pattern.
|
36 |
+
|
37 |
+
- **Models:** Machine learning models for image classification.
|
38 |
+
- **Views:** HTML templates with dynamic JavaScript interactivity.
|
39 |
+
- **Controllers:** Flask routes for handling predictions and LLM queries.
|
40 |
+
## Frontend
|
41 |
+
|
42 |
+
**Tabs:**
|
43 |
+
The main interface consists of four tabs:
|
44 |
+
|
45 |
+
1. Gastrointestinal Disease Prediction
|
46 |
+
2. Chest CT Disease Prediction
|
47 |
+
3. Chest X-ray Disease Prediction
|
48 |
+
4. LLM Chat
|
49 |
+
|
50 |
+
Each tab contains:
|
51 |
+
- A form to upload an image and submit for prediction.
|
52 |
+
- A results section for displaying the prediction.
|
53 |
+
- Dropdowns for research papers and case reports
|
54 |
+
**User Interaction:**
|
55 |
+
- **File Upload:** Users can upload an image for disease prediction.
|
56 |
+
- **Prediction Result Display:** The model's prediction is displayed after analysis.
|
57 |
+
- **Research Links & Case Reports:** These links are loaded dynamically based on the prediction.
|
58 |
+
- **LLM Prompt Bar:** At the bottom, users can type a question to ask the assistant and get a response.
|
59 |
+
|
60 |
+
**Styling:**
|
61 |
+
The UI is clean with a modern design. A dark mode and light-themed background with disease-specific images that change continuously create a professional appearance. Hover effects on the research and case report links provide better interactivity.
|
62 |
+
## Backend
|
63 |
+
The backend of the project is powered by `Flask`. Below are the key elements:
|
64 |
+
|
65 |
+
**Routes:**
|
66 |
+
|
67 |
+
1. **Prediction Routes:**
|
68 |
+
|
69 |
+
`/predict_gastrointestinal`
|
70 |
+
|
71 |
+
`/predict_chest_ct`
|
72 |
+
|
73 |
+
`/predict_chest_xray`
|
74 |
+
|
75 |
+
Each route handles a POST request with an uploaded image, passes it to the corresponding model, and returns a prediction.
|
76 |
+
|
77 |
+
2. **LLM Query Route:**
|
78 |
+
|
79 |
+
`/ask_llm`
|
80 |
+
|
81 |
+
This route accepts a user query and sends it to the LLM API to retrieve a text-based answer.
|
82 |
+
|
83 |
+
|
84 |
+
**Handling Predictions**
|
85 |
+
|
86 |
+
For each prediction:
|
87 |
+
|
88 |
+
1. **Image Preprocessing:** Uploaded images are processed (resizing, normalization, etc.).
|
89 |
+
2. **Model Inference:** The processed image is passed to the corresponding machine learning model for prediction.
|
90 |
+
3. **Prediction Result:** The result is sent back to the frontend and displayed in the UI.
|
91 |
+
|
92 |
+
## Models
|
93 |
+
|
94 |
+
1. **Gastrointestinal Model:**
|
95 |
+
- **Task:** Classify images into four categories: Diverticulosis, Neoplasm, Peritonitis, and Ureters.
|
96 |
+
- **Dataset:** Gastrointestinal endoscopic images.
|
97 |
+
- **Architecture:** Transfer learning using a pre-trained transformer model i.e Swin.
|
98 |
+
|
99 |
+
2. **Chest CT Model:**
|
100 |
+
- **Task:** Classify Chest CT-Scan images into four categories: Adenocarcinoma, Large cell carcinoma, Squamous cell carcinoma, and Normal.
|
101 |
+
- **Dataset:** Chest CT images (split into training, validation, and test sets).
|
102 |
+
- **Architecture:** Transfer learning using a pre-trained transformer model i.e Swin.
|
103 |
+
|
104 |
+
3. **Chest X-ray Model:**
|
105 |
+
- **Task:** Classify Chest X-rays into two categories: Pneumonia and Normal.
|
106 |
+
- **Dataset:** Chest X-ray dataset.
|
107 |
+
- **Architecture:** Transfer learning using a pre-trained transformer model (i.e Vision Transformer).
|
108 |
+
Each model outputs a prediction for its respective image, which is then used to populate research links and case reports.
|
109 |
+
## LLM Integration
|
110 |
+
|
111 |
+
|
112 |
+
The application integrates with LLaMA 3.1 API to provide a conversational interface where users can ask medical-related questions.
|
113 |
+
|
114 |
+
**Workflow:**
|
115 |
+
|
116 |
+
1. Users enter their query in the prompt bar.
|
117 |
+
2. The query is sent via a POST request to `/ask_llm`.
|
118 |
+
3. The backend forwards the request to the LLM API.
|
119 |
+
4. The API response is sent back to the frontend and displayed as an answer.
|
120 |
+
## Project Structure
|
121 |
+
|
122 |
+
Health Vision AI/
|
123 |
+
βββ static/
|
124 |
+
β βββ styles.css # Custom CSS for styling
|
125 |
+
β βββ images/ # Images for background (optional)
|
126 |
+
βββ templates/
|
127 |
+
β βββ index.html # Main HTML file
|
128 |
+
βββ models/
|
129 |
+
β βββ gastro_model.h5 # Gastrointestinal model
|
130 |
+
β βββ chest_ct_model.h5 # Chest CT model
|
131 |
+
β βββ chest_xray_model.h5# Chest X-ray model
|
132 |
+
β βββ LLM # LLM model
|
133 |
+
βββ app.py # Flask application
|
134 |
+
βββ requirements.txt # Required Python packages
|
135 |
+
βββ README.md # Project documentation
|
136 |
+
|
137 |
+
## Usage
|
138 |
+
|
139 |
+
**Image Prediction:**
|
140 |
+
|
141 |
+
- Navigate to the appropriate tab (Gastrointestinal, Chest CT, Chest X-ray).
|
142 |
+
- Upload an image and click Predict.
|
143 |
+
- The prediction will be displayed along with links to research papers and case reports.
|
144 |
+
|
145 |
+
**LLM Query:**
|
146 |
+
|
147 |
+
- Enter a question in the prompt bar at the bottom.
|
148 |
+
- Click Ask to get an answer from the AI assistant.
|
149 |
+
## Future Improvements
|
150 |
+
|
151 |
+
- **Enhanced LLM:** Improve the LLM integration to offer more advanced medical advice based on user input.
|
152 |
+
- **Database Integration:** Store past predictions and questions for reference.
|
153 |
+
- **User Accounts:** Implement user authentication for storing personal data and history.
|
154 |
+
- **Performance Optimizations:** Speed up model inference for large images using optimized backend processing.
|