Upload 25 files
Browse files- .gitattributes +4 -0
- app.py +173 -0
- models/LLM/config.json +46 -0
- models/LLM/generation_config.json +6 -0
- models/LLM/merges.txt +0 -0
- models/LLM/model.safetensors +3 -0
- models/LLM/special_tokens_map.json +6 -0
- models/LLM/tokenizer.json +0 -0
- models/LLM/tokenizer_config.json +20 -0
- models/LLM/vocab.json +0 -0
- models/chest_ct_model_swin.pth +3 -0
- models/chest_xray_vit.pth +3 -0
- models/gastrointestinal_model_swin.pth +3 -0
- static/images/back1.jpg +3 -0
- static/images/back2.jpg +0 -0
- static/images/back3.jpg +3 -0
- static/images/back4.jpeg +0 -0
- static/images/back5.jpg +3 -0
- static/images/back6.jpg +3 -0
- static/images/back7.jpg +0 -0
- static/images/background.jpeg +0 -0
- static/images/chest_ct.jpeg +0 -0
- static/images/chest_xray.jpeg +0 -0
- static/images/gastro.jpeg +0 -0
- static/styles.css +184 -0
- templates/index.html +301 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
static/images/back1.jpg filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
static/images/back3.jpg filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
static/images/back5.jpg filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
static/images/back6.jpg filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, request, jsonify, render_template
|
| 2 |
+
import torch
|
| 3 |
+
from torchvision import transforms
|
| 4 |
+
from PIL import Image
|
| 5 |
+
import os
|
| 6 |
+
import torch.nn as nn
|
| 7 |
+
import timm
|
| 8 |
+
from torchvision.models import swin_t, Swin_T_Weights, vit_b_16, ViT_B_16_Weights
|
| 9 |
+
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
| 10 |
+
|
| 11 |
+
app = Flask(__name__)
|
| 12 |
+
|
| 13 |
+
# Set up directories for uploads and models
|
| 14 |
+
UPLOAD_FOLDER = os.path.join('static', 'uploads')
|
| 15 |
+
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
| 16 |
+
|
| 17 |
+
# Device configuration
|
| 18 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 19 |
+
|
| 20 |
+
# Load the LLM model and tokenizer
|
| 21 |
+
model = GPT2LMHeadModel.from_pretrained('models\\LLM').to(device)
|
| 22 |
+
tokenizer = GPT2Tokenizer.from_pretrained('models\\LLM')
|
| 23 |
+
separator_token = tokenizer.eos_token # Separator token for the model
|
| 24 |
+
|
| 25 |
+
# Define and load the pre-trained Swin models
|
| 26 |
+
|
| 27 |
+
# Gastrointestinal Model (4 classes: Diverticulosis, Neoplasm, Peritonitis, Ureters)
|
| 28 |
+
gastrointestinal_classes = ['Diverticulosis', 'Neoplasm', 'Peritonitis', 'Ureters']
|
| 29 |
+
gastrointestinal_model = timm.create_model('swin_base_patch4_window7_224', pretrained=True)
|
| 30 |
+
gastrointestinal_model.head = nn.Linear(gastrointestinal_model.head.in_features, len(gastrointestinal_classes))
|
| 31 |
+
gastrointestinal_model = gastrointestinal_model.to(device)
|
| 32 |
+
gastrointestinal_model.load_state_dict(torch.load('models\\gastrointestinal_model_swin.pth', map_location=device, weights_only=True), strict=False)
|
| 33 |
+
gastrointestinal_model.eval()
|
| 34 |
+
|
| 35 |
+
# Chest CT Model (4 classes: Adenocarcinoma, Large cell carcinoma, Normal, Squamous cell carcinoma)
|
| 36 |
+
chest_ct_classes = ['Adenocarcinoma', 'Large Cell Carcinoma', 'Normal', 'Squamous Cell Carcinoma']
|
| 37 |
+
chest_ct_model = swin_t(weights=Swin_T_Weights.IMAGENET1K_V1)
|
| 38 |
+
chest_ct_model.head = nn.Linear(chest_ct_model.head.in_features, len(chest_ct_classes))
|
| 39 |
+
chest_ct_model = chest_ct_model.to(device)
|
| 40 |
+
chest_ct_model.load_state_dict(torch.load('models\\best_model.pth', map_location=device, weights_only=True), strict=False)
|
| 41 |
+
chest_ct_model.eval()
|
| 42 |
+
|
| 43 |
+
# Chest X-ray Model (2 classes: Normal, Pneumonia)
|
| 44 |
+
chest_xray_classes = ['Normal', 'Pneumonia']
|
| 45 |
+
chest_xray_model = vit_b_16(weights=ViT_B_16_Weights.IMAGENET1K_V1)
|
| 46 |
+
chest_xray_model.heads.head = nn.Linear(chest_xray_model.heads.head.in_features, len(chest_xray_classes))
|
| 47 |
+
chest_xray_model = chest_xray_model.to(device)
|
| 48 |
+
chest_xray_model.load_state_dict(torch.load('models\\best_model_vit_chest_xray.pth', map_location=device, weights_only=True), strict=False)
|
| 49 |
+
chest_xray_model.eval()
|
| 50 |
+
|
| 51 |
+
# Image transformation (same for all models)
|
| 52 |
+
transform = transforms.Compose([
|
| 53 |
+
transforms.Resize((224, 224)),
|
| 54 |
+
transforms.ToTensor(),
|
| 55 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
|
| 56 |
+
])
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
# Helper function to load and transform images
|
| 60 |
+
def process_image(image_path):
|
| 61 |
+
image = Image.open(image_path).convert('RGB')
|
| 62 |
+
return transform(image).unsqueeze(0).to(device)
|
| 63 |
+
|
| 64 |
+
# LLM helper function to generate answers
|
| 65 |
+
def generate_answer(question, max_length=1024):
|
| 66 |
+
model.eval() # Set the model to evaluation mode
|
| 67 |
+
input_text = question + separator_token
|
| 68 |
+
input_ids = tokenizer.encode(input_text, return_tensors='pt').to(device)
|
| 69 |
+
|
| 70 |
+
output = model.generate(input_ids, max_length=max_length, pad_token_id=tokenizer.eos_token_id)
|
| 71 |
+
answer = tokenizer.decode(output[:, input_ids.shape[-1]:][0], skip_special_tokens=True)
|
| 72 |
+
return answer
|
| 73 |
+
|
| 74 |
+
# Prediction routes for each model
|
| 75 |
+
@app.route('/predict_gastrointestinal', methods=['POST'])
|
| 76 |
+
def predict_gastrointestinal():
|
| 77 |
+
if 'file' not in request.files:
|
| 78 |
+
return jsonify({"error": "No file uploaded"}), 400
|
| 79 |
+
|
| 80 |
+
file = request.files['file']
|
| 81 |
+
file_path = os.path.join(app.config['UPLOAD_FOLDER'], file.filename)
|
| 82 |
+
file.save(file_path)
|
| 83 |
+
|
| 84 |
+
# Preprocess the image
|
| 85 |
+
image_tensor = process_image(file_path)
|
| 86 |
+
|
| 87 |
+
# Make prediction using the gastrointestinal model
|
| 88 |
+
with torch.no_grad():
|
| 89 |
+
output = gastrointestinal_model(image_tensor)
|
| 90 |
+
|
| 91 |
+
# Ensure the output tensor has the right shape and handle it
|
| 92 |
+
|
| 93 |
+
# If the output has extra dimensions, flatten it
|
| 94 |
+
if len(output.shape) > 2:
|
| 95 |
+
output = output.view(output.size(0), -1)
|
| 96 |
+
|
| 97 |
+
# Check if output is for a batch or single sample
|
| 98 |
+
if output.size(0) != 1:
|
| 99 |
+
return jsonify({"error": "Unexpected output size"}), 500
|
| 100 |
+
|
| 101 |
+
# Get the predicted class (ensure it's scalar)
|
| 102 |
+
_, predicted = torch.max(output, 1)
|
| 103 |
+
predicted_class = gastrointestinal_classes[predicted.item()]
|
| 104 |
+
|
| 105 |
+
return jsonify({'prediction': predicted_class})
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
@app.route('/predict_chest_ct', methods=['POST'])
|
| 109 |
+
def predict_chest_ct():
|
| 110 |
+
if 'file' not in request.files:
|
| 111 |
+
return jsonify({"error": "No file uploaded"}), 400
|
| 112 |
+
|
| 113 |
+
file = request.files['file']
|
| 114 |
+
file_path = os.path.join(app.config['UPLOAD_FOLDER'], file.filename)
|
| 115 |
+
file.save(file_path)
|
| 116 |
+
|
| 117 |
+
# Preprocess the image
|
| 118 |
+
image_tensor = process_image(file_path)
|
| 119 |
+
|
| 120 |
+
# Make prediction using the chest CT model
|
| 121 |
+
with torch.no_grad():
|
| 122 |
+
output = chest_ct_model(image_tensor)
|
| 123 |
+
_, predicted = torch.max(output, 1)
|
| 124 |
+
predicted_class = chest_ct_classes[predicted.item()]
|
| 125 |
+
|
| 126 |
+
return jsonify({'prediction': predicted_class})
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
@app.route('/predict_chest_xray', methods=['POST'])
|
| 130 |
+
def predict_chest_xray():
|
| 131 |
+
if 'file' not in request.files:
|
| 132 |
+
return jsonify({"error": "No file uploaded"}), 400
|
| 133 |
+
|
| 134 |
+
file = request.files['file']
|
| 135 |
+
file_path = os.path.join(app.config['UPLOAD_FOLDER'], file.filename)
|
| 136 |
+
file.save(file_path)
|
| 137 |
+
|
| 138 |
+
# Preprocess the image
|
| 139 |
+
image_tensor = process_image(file_path)
|
| 140 |
+
|
| 141 |
+
# Make prediction using the chest X-ray model
|
| 142 |
+
with torch.no_grad():
|
| 143 |
+
output = chest_xray_model(image_tensor)
|
| 144 |
+
_, predicted = torch.max(output, 1)
|
| 145 |
+
predicted_class = chest_xray_classes[predicted.item()]
|
| 146 |
+
|
| 147 |
+
return jsonify({'prediction': predicted_class})
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
# New LLM route for asking questions
|
| 151 |
+
@app.route('/ask_llm', methods=['POST'])
|
| 152 |
+
def ask_llm():
|
| 153 |
+
user_question = request.json.get('question', None)
|
| 154 |
+
|
| 155 |
+
if not user_question:
|
| 156 |
+
return jsonify({"error": "No question provided"}), 400
|
| 157 |
+
|
| 158 |
+
try:
|
| 159 |
+
# Generate answer using the fine-tuned GPT-2 model
|
| 160 |
+
answer = generate_answer(user_question)
|
| 161 |
+
except Exception as e:
|
| 162 |
+
return jsonify({"error": f"An error occurred: {str(e)}"}), 500
|
| 163 |
+
|
| 164 |
+
return jsonify({'answer': answer})
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
# Main route for the homepage
|
| 168 |
+
@app.route('/')
|
| 169 |
+
def index():
|
| 170 |
+
return render_template('index.html')
|
| 171 |
+
|
| 172 |
+
if __name__ == "__main__":
|
| 173 |
+
app.run(debug=True)
|
models/LLM/config.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "distilgpt2",
|
| 3 |
+
"_num_labels": 1,
|
| 4 |
+
"activation_function": "gelu_new",
|
| 5 |
+
"architectures": [
|
| 6 |
+
"GPT2LMHeadModel"
|
| 7 |
+
],
|
| 8 |
+
"attn_pdrop": 0.1,
|
| 9 |
+
"bos_token_id": 50256,
|
| 10 |
+
"embd_pdrop": 0.1,
|
| 11 |
+
"eos_token_id": 50256,
|
| 12 |
+
"id2label": {
|
| 13 |
+
"0": "LABEL_0"
|
| 14 |
+
},
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"label2id": {
|
| 17 |
+
"LABEL_0": 0
|
| 18 |
+
},
|
| 19 |
+
"layer_norm_epsilon": 1e-05,
|
| 20 |
+
"model_type": "gpt2",
|
| 21 |
+
"n_ctx": 1024,
|
| 22 |
+
"n_embd": 768,
|
| 23 |
+
"n_head": 12,
|
| 24 |
+
"n_inner": null,
|
| 25 |
+
"n_layer": 6,
|
| 26 |
+
"n_positions": 1024,
|
| 27 |
+
"reorder_and_upcast_attn": false,
|
| 28 |
+
"resid_pdrop": 0.1,
|
| 29 |
+
"scale_attn_by_inverse_layer_idx": false,
|
| 30 |
+
"scale_attn_weights": true,
|
| 31 |
+
"summary_activation": null,
|
| 32 |
+
"summary_first_dropout": 0.1,
|
| 33 |
+
"summary_proj_to_labels": true,
|
| 34 |
+
"summary_type": "cls_index",
|
| 35 |
+
"summary_use_proj": true,
|
| 36 |
+
"task_specific_params": {
|
| 37 |
+
"text-generation": {
|
| 38 |
+
"do_sample": true,
|
| 39 |
+
"max_length": 50
|
| 40 |
+
}
|
| 41 |
+
},
|
| 42 |
+
"torch_dtype": "float32",
|
| 43 |
+
"transformers_version": "4.44.2",
|
| 44 |
+
"use_cache": true,
|
| 45 |
+
"vocab_size": 50257
|
| 46 |
+
}
|
models/LLM/generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 50256,
|
| 4 |
+
"eos_token_id": 50256,
|
| 5 |
+
"transformers_version": "4.44.2"
|
| 6 |
+
}
|
models/LLM/merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
models/LLM/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:be1dd397ce1983f5a553f6c5f9aa65f22260e75a8ba77ebf91ee75c6dcac2118
|
| 3 |
+
size 327657928
|
models/LLM/special_tokens_map.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "<|endoftext|>",
|
| 3 |
+
"eos_token": "<|endoftext|>",
|
| 4 |
+
"pad_token": "<|endoftext|>",
|
| 5 |
+
"unk_token": "<|endoftext|>"
|
| 6 |
+
}
|
models/LLM/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
models/LLM/tokenizer_config.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"added_tokens_decoder": {
|
| 4 |
+
"50256": {
|
| 5 |
+
"content": "<|endoftext|>",
|
| 6 |
+
"lstrip": false,
|
| 7 |
+
"normalized": true,
|
| 8 |
+
"rstrip": false,
|
| 9 |
+
"single_word": false,
|
| 10 |
+
"special": true
|
| 11 |
+
}
|
| 12 |
+
},
|
| 13 |
+
"bos_token": "<|endoftext|>",
|
| 14 |
+
"clean_up_tokenization_spaces": true,
|
| 15 |
+
"eos_token": "<|endoftext|>",
|
| 16 |
+
"model_max_length": 1024,
|
| 17 |
+
"pad_token": "<|endoftext|>",
|
| 18 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 19 |
+
"unk_token": "<|endoftext|>"
|
| 20 |
+
}
|
models/LLM/vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
models/chest_ct_model_swin.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:789bda3e8a7908341b793cff4d88dc01b823953a076eab42ba9c8fc26018d9cc
|
| 3 |
+
size 110386359
|
models/chest_xray_vit.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dc43ca56aeb7922c689380f34c020f1bb88859511e159c4b47a5a7155b4a48be
|
| 3 |
+
size 343263994
|
models/gastrointestinal_model_swin.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bc0180d6a9c4bc375fa20cf52adbecffeb274c8f285768fe96e31985532b47c8
|
| 3 |
+
size 347124772
|
static/images/back1.jpg
ADDED
|
Git LFS Details
|
static/images/back2.jpg
ADDED
|
static/images/back3.jpg
ADDED
|
Git LFS Details
|
static/images/back4.jpeg
ADDED
|
static/images/back5.jpg
ADDED
|
Git LFS Details
|
static/images/back6.jpg
ADDED
|
Git LFS Details
|
static/images/back7.jpg
ADDED
|
static/images/background.jpeg
ADDED
|
static/images/chest_ct.jpeg
ADDED
|
static/images/chest_xray.jpeg
ADDED
|
static/images/gastro.jpeg
ADDED
|
static/styles.css
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* General Styles */
|
| 2 |
+
body {
|
| 3 |
+
margin: 0;
|
| 4 |
+
font-family: Arial, sans-serif;
|
| 5 |
+
background-color: #f0f8ff;
|
| 6 |
+
background-image: url('/static/images/back3.jpg');
|
| 7 |
+
background-size: cover;
|
| 8 |
+
background-position: center;
|
| 9 |
+
animation: backgroundChange 15s infinite;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
button, .research-link, .case-report-link, input[type="file"] {
|
| 13 |
+
background-color: #4682b4;
|
| 14 |
+
color: white;
|
| 15 |
+
padding: 10px 20px;
|
| 16 |
+
border: none;
|
| 17 |
+
border-radius: 5px;
|
| 18 |
+
cursor: pointer;
|
| 19 |
+
font-size: 16px;
|
| 20 |
+
transition: background-color 0.3s ease;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
button:hover, .research-link:hover, .case-report-link:hover, input[type="file"]:hover {
|
| 24 |
+
background-color: #03355e;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
.container {
|
| 28 |
+
text-align: center;
|
| 29 |
+
padding: 50px;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
h1 {
|
| 33 |
+
font-size: 2.5em;
|
| 34 |
+
color: #00000022;
|
| 35 |
+
margin-bottom: 20px;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/* Tab Styles */
|
| 39 |
+
.tabs {
|
| 40 |
+
display: flex;
|
| 41 |
+
justify-content: center;
|
| 42 |
+
margin-bottom: 20px;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
.tab-button {
|
| 46 |
+
background-color: #4682b4;
|
| 47 |
+
color: rgb(0, 0, 0);
|
| 48 |
+
border: none;
|
| 49 |
+
padding: 10px 20px;
|
| 50 |
+
margin: 0 5px;
|
| 51 |
+
cursor: pointer;
|
| 52 |
+
font-size: 1.1em;
|
| 53 |
+
transition: background-color 0.3s ease;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
.tab-button:hover {
|
| 57 |
+
background-color: #03355e;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
.tab-button.active {
|
| 61 |
+
background-color: #ffffff;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
.tab-content {
|
| 65 |
+
display: none;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.tab-content.active {
|
| 69 |
+
display: block;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
form {
|
| 73 |
+
margin-bottom: 20px;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
label {
|
| 77 |
+
font-size: 1.2em;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
input[type="file"], input[type="text"] {
|
| 81 |
+
margin: 10px 0;
|
| 82 |
+
padding: 10px;
|
| 83 |
+
width: 100%;
|
| 84 |
+
max-width: 500px;
|
| 85 |
+
border: 1px solid #ccc;
|
| 86 |
+
border-radius: 5px;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
button[type="submit"], button[type="button"] {
|
| 90 |
+
background-color: #5a9bd4;
|
| 91 |
+
color: white;
|
| 92 |
+
padding: 10px 20px;
|
| 93 |
+
border: none;
|
| 94 |
+
font-size: 1.1em;
|
| 95 |
+
cursor: pointer;
|
| 96 |
+
transition: background-color 0.3s ease;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
button:hover {
|
| 100 |
+
background-color: #03355e;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/* Prediction Result */
|
| 104 |
+
.prediction-result {
|
| 105 |
+
margin-top: 20px;
|
| 106 |
+
font-size: 1.5em;
|
| 107 |
+
color: #000000;
|
| 108 |
+
opacity: 1;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
/* Dropdown Links Styling */
|
| 112 |
+
.resources ul {
|
| 113 |
+
list-style-type: none;
|
| 114 |
+
padding: 0;
|
| 115 |
+
margin: 0;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
.resources ul li {
|
| 119 |
+
margin: 5px 0;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
.resources ul li a {
|
| 123 |
+
background-color: #f9a825; /* Bright yellow background */
|
| 124 |
+
color: white; /* White text */
|
| 125 |
+
padding: 10px;
|
| 126 |
+
border-radius: 5px;
|
| 127 |
+
text-decoration: none;
|
| 128 |
+
display: block;
|
| 129 |
+
transition: background-color 0.3s ease;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
.resources ul li a:hover {
|
| 133 |
+
background-color: #f57f17; /* Darker yellow on hover */
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
/* Adding space between prediction result and research buttons */
|
| 137 |
+
.prediction-result {
|
| 138 |
+
margin-bottom: 20px; /* Adding space below the prediction result */
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
/* LLM Prompt Bar */
|
| 143 |
+
.llm-prompt-bar {
|
| 144 |
+
position: fixed;
|
| 145 |
+
bottom: 0;
|
| 146 |
+
width: 100%;
|
| 147 |
+
background-color: #333;
|
| 148 |
+
padding: 10px;
|
| 149 |
+
text-align: center;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
.llm-prompt-bar input[type="text"] {
|
| 153 |
+
width: 70%;
|
| 154 |
+
padding: 10px;
|
| 155 |
+
font-size: 1.1em;
|
| 156 |
+
border: none;
|
| 157 |
+
border-radius: 5px;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
.llm-prompt-bar button {
|
| 161 |
+
background-color: #5a9bd4;
|
| 162 |
+
color: white;
|
| 163 |
+
padding: 10px 20px;
|
| 164 |
+
border: none;
|
| 165 |
+
cursor: pointer;
|
| 166 |
+
font-size: 1.1em;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
.llm-prompt-bar button:hover {
|
| 170 |
+
background-color: #03355e;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
/* Background Change Animation */
|
| 174 |
+
@keyframes backgroundChange {
|
| 175 |
+
0% {
|
| 176 |
+
background-image: url('/static/images/back5.jpg');
|
| 177 |
+
}
|
| 178 |
+
50% {
|
| 179 |
+
background-image: url('/static/images/back6.jpg');
|
| 180 |
+
}
|
| 181 |
+
100% {
|
| 182 |
+
background-image: url('/static/images/back7.jpg');
|
| 183 |
+
}
|
| 184 |
+
}
|
templates/index.html
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>AI Health Assistant</title>
|
| 7 |
+
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
|
| 8 |
+
<style>
|
| 9 |
+
/* Additional styles for dropdown functionality */
|
| 10 |
+
.dropdown {
|
| 11 |
+
position: relative;
|
| 12 |
+
display: inline-block;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
.dropdown-content {
|
| 16 |
+
display: none;
|
| 17 |
+
position: absolute;
|
| 18 |
+
background-color: #10477d;
|
| 19 |
+
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
|
| 20 |
+
z-index: 1;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
.dropdown-content a {
|
| 24 |
+
color: black;
|
| 25 |
+
padding: 12px 16px;
|
| 26 |
+
text-decoration: none;
|
| 27 |
+
display: block;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
.dropdown-content a:hover {
|
| 31 |
+
background-color: #f1f1f153;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.dropdown:hover .dropdown-content {
|
| 35 |
+
display: block;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.dropdown:hover .dropbtn {
|
| 39 |
+
background-color: #072d4d;
|
| 40 |
+
}
|
| 41 |
+
</style>
|
| 42 |
+
</head>
|
| 43 |
+
<body>
|
| 44 |
+
<div class="container">
|
| 45 |
+
<h1>AI Health Assistant</h1>
|
| 46 |
+
|
| 47 |
+
<!-- Tab Buttons -->
|
| 48 |
+
<div class="tabs">
|
| 49 |
+
<button class="tab-button active" data-target="gastrointestinal">Gastrointestinal Disease Prediction</button>
|
| 50 |
+
<button class="tab-button" data-target="chest_ct">Chest CT Disease Prediction</button>
|
| 51 |
+
<button class="tab-button" data-target="chest_xray">Chest X-ray Disease Prediction</button>
|
| 52 |
+
<button class="tab-button" data-target="llm">Chat</button>
|
| 53 |
+
</div>
|
| 54 |
+
|
| 55 |
+
<!-- Gastrointestinal Model Form -->
|
| 56 |
+
<div id="gastrointestinal" class="tab-content active">
|
| 57 |
+
<h2>Upload Image for Gastrointestinal Disease Prediction</h2>
|
| 58 |
+
<form id="gastrointestinal-form" enctype="multipart/form-data">
|
| 59 |
+
<label for="file">Select Image:</label>
|
| 60 |
+
<input type="file" name="file" id="gastrointestinal-file" required>
|
| 61 |
+
<button type="button" onclick="predictDisease('gastrointestinal')">Predict</button>
|
| 62 |
+
</form>
|
| 63 |
+
<div class="prediction-result" id="gastrointestinal-result"></div>
|
| 64 |
+
|
| 65 |
+
<!-- Dropdown for Research Links -->
|
| 66 |
+
<div class="dropdown">
|
| 67 |
+
<button class="dropbtn">Research Papers</button>
|
| 68 |
+
<div class="dropdown-content" id="gastrointestinal-research-links"></div>
|
| 69 |
+
</div>
|
| 70 |
+
<!-- Dropdown for Case Reports -->
|
| 71 |
+
<div class="dropdown">
|
| 72 |
+
<button class="dropbtn">Case Reports</button>
|
| 73 |
+
<div class="dropdown-content" id="gastrointestinal-case-report-links"></div>
|
| 74 |
+
</div>
|
| 75 |
+
</div>
|
| 76 |
+
|
| 77 |
+
<!-- Chest CT Model Form -->
|
| 78 |
+
<div id="chest_ct" class="tab-content">
|
| 79 |
+
<h2>Upload Image for Chest CT Disease Prediction</h2>
|
| 80 |
+
<form id="chest_ct-form" enctype="multipart/form-data">
|
| 81 |
+
<label for="file">Select Image:</label>
|
| 82 |
+
<input type="file" name="file" id="ct-file" required>
|
| 83 |
+
<button type="button" onclick="predictDisease('chest_ct')">Predict</button>
|
| 84 |
+
</form>
|
| 85 |
+
<div class="prediction-result" id="chest_ct-result"></div>
|
| 86 |
+
|
| 87 |
+
<!-- Dropdown for Research Links -->
|
| 88 |
+
<div class="dropdown">
|
| 89 |
+
<button class="dropbtn">Research Papers</button>
|
| 90 |
+
<div class="dropdown-content" id="chest_ct-research-links"></div>
|
| 91 |
+
</div>
|
| 92 |
+
<!-- Dropdown for Case Reports -->
|
| 93 |
+
<div class="dropdown">
|
| 94 |
+
<button class="dropbtn">Case Reports</button>
|
| 95 |
+
<div class="dropdown-content" id="chest_ct-case-report-links"></div>
|
| 96 |
+
</div>
|
| 97 |
+
</div>
|
| 98 |
+
|
| 99 |
+
<!-- Chest X-ray Model Form -->
|
| 100 |
+
<div id="chest_xray" class="tab-content">
|
| 101 |
+
<h2>Upload Image for Chest X-ray Disease Prediction</h2>
|
| 102 |
+
<form id="chest_xray-form" enctype="multipart/form-data">
|
| 103 |
+
<label for="file">Select Image:</label>
|
| 104 |
+
<input type="file" name="file" id="xray-file" required>
|
| 105 |
+
<button type="button" onclick="predictDisease('chest_xray')">Predict</button>
|
| 106 |
+
</form>
|
| 107 |
+
<div class="prediction-result" id="chest_xray-result"></div>
|
| 108 |
+
|
| 109 |
+
<!-- Dropdown for Research Links -->
|
| 110 |
+
<div class="dropdown">
|
| 111 |
+
<button class="dropbtn">Research Papers</button>
|
| 112 |
+
<div class="dropdown-content" id="chest_xray-research-links"></div>
|
| 113 |
+
</div>
|
| 114 |
+
<!-- Dropdown for Case Reports -->
|
| 115 |
+
<div class="dropdown">
|
| 116 |
+
<button class="dropbtn">Case Reports</button>
|
| 117 |
+
<div class="dropdown-content" id="chest_xray-case-report-links"></div>
|
| 118 |
+
</div>
|
| 119 |
+
</div>
|
| 120 |
+
|
| 121 |
+
<!-- Chat with LLM -->
|
| 122 |
+
<div id="llm" class="tab-content">
|
| 123 |
+
<h2>Ask the AI Health Assistant</h2>
|
| 124 |
+
<div id="llm-answer"></div>
|
| 125 |
+
</div>
|
| 126 |
+
</div>
|
| 127 |
+
|
| 128 |
+
<!-- LLM Prompt Bar at the Bottom -->
|
| 129 |
+
<div class="llm-prompt-bar">
|
| 130 |
+
<input type="text" id="llm-prompt" placeholder="Ask your question here...">
|
| 131 |
+
<button onclick="askLLM()">Ask</button>
|
| 132 |
+
</div>
|
| 133 |
+
|
| 134 |
+
<!-- Scripts -->
|
| 135 |
+
<script>
|
| 136 |
+
const researchLinks = {
|
| 137 |
+
'Diverticulosis': {
|
| 138 |
+
papers: [
|
| 139 |
+
{ title: 'Diverticulosis Research Paper 1', url: 'https://www.ncbi.nlm.nih.gov/books/NBK430771/' },
|
| 140 |
+
{ title: 'Diverticulosis Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC10410187/' }
|
| 141 |
+
],
|
| 142 |
+
reports: [
|
| 143 |
+
{ title: 'Diverticulosis Case Report 1', url: 'https://jmedicalcasereports.biomedcentral.com/articles/10.1186/1752-1947-4-172' },
|
| 144 |
+
{ title: 'Diverticulosis Case Report 2', url: 'https://wjes.biomedcentral.com/articles/10.1186/1749-7922-3-10' },
|
| 145 |
+
{ title: 'Diverticulosis Case Report 3', url: 'https://www.sciencedirect.com/science/article/pii/S2210261223000743' }
|
| 146 |
+
]
|
| 147 |
+
},
|
| 148 |
+
'Neoplasm': {
|
| 149 |
+
papers: [
|
| 150 |
+
{ title: 'Neoplasm Research Paper 1', url: 'https://www.sciencedirect.com/topics/pharmacology-toxicology-and-pharmaceutical-science/neoplasm' },
|
| 151 |
+
{ title: 'Neoplasm Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC9846320/' }
|
| 152 |
+
],
|
| 153 |
+
reports: [
|
| 154 |
+
{ title: 'Neoplasm Case Report 1', url: 'https://bmcwomenshealth.biomedcentral.com/articles/10.1186/s12905-022-01766-2' },
|
| 155 |
+
{ title: 'Neoplasm Case Report 2', url: 'https://issoonline.biomedcentral.com/articles/10.1186/1477-7800-6-6' },
|
| 156 |
+
{ title: 'Neoplasm Case Report 3', url: 'https://wjso.biomedcentral.com/articles/10.1186/1477-7819-5-98' }
|
| 157 |
+
]
|
| 158 |
+
},
|
| 159 |
+
'Peritonitis': {
|
| 160 |
+
papers: [
|
| 161 |
+
{ title: 'Peritonitis Research Paper 1', url: 'https://my.clevelandclinic.org/health/diseases/17831-peritonitis' },
|
| 162 |
+
{ title: 'Peritonitis Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7152366/' }
|
| 163 |
+
],
|
| 164 |
+
reports: [
|
| 165 |
+
{ title: 'Peritonitis Case Report 1', url: 'https://pubmed.ncbi.nlm.nih.gov/11396540/' },
|
| 166 |
+
{ title: 'Peritonitis Case Report 2', url: 'https://bmcinfectdis.biomedcentral.com/articles/10.1186/1471-2334-13-S1-P34' },
|
| 167 |
+
{ title: 'Peritonitis Case Report 3', url: 'https://ccforum.biomedcentral.com/articles/10.1186/cc12906' }
|
| 168 |
+
]
|
| 169 |
+
},
|
| 170 |
+
'Ureters': {
|
| 171 |
+
papers: [
|
| 172 |
+
{ title: 'Ureters Research Paper 1', url: 'https://www.sciencedirect.com/topics/medicine-and-dentistry/ureter-disease' },
|
| 173 |
+
{ title: 'Ureters Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/books/NBK507817/' }
|
| 174 |
+
],
|
| 175 |
+
reports: [
|
| 176 |
+
{ title: 'Ureters Case Report 1', url: 'https://bmcurol.biomedcentral.com/articles/10.1186/1471-2490-12-35' },
|
| 177 |
+
{ title: 'Ureters Case Report 2', url: 'https://bmcurol.biomedcentral.com/articles/10.1186/s12894-018-0396-6' },
|
| 178 |
+
{ title: 'Ureters Case Report 3', url: 'https://bmcurol.biomedcentral.com/articles/10.1186/s12894-018-0396-6' }
|
| 179 |
+
]
|
| 180 |
+
},
|
| 181 |
+
'Large Cell Carcinoma': {
|
| 182 |
+
papers: [
|
| 183 |
+
{ title: 'Large Cell Carcinoma Research Paper 1', url: 'https://www.sciencedirect.com/topics/pharmacology-toxicology-and-pharmaceutical-science/large-cell-carcinoma' },
|
| 184 |
+
{ title: 'Large Cell Carcinoma Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4531643/' }
|
| 185 |
+
],
|
| 186 |
+
reports: [
|
| 187 |
+
{ title: 'Large Cell Carcinoma Case Report 1', url: 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7481563/' },
|
| 188 |
+
{ title: 'Large Cell Carcinoma Case Report 2', url: 'https://wjso.biomedcentral.com/articles/10.1186/1477-7819-11-205' },
|
| 189 |
+
{ title: 'Large Cell Carcinoma Case Report 3', url: 'https://cardiothoracicsurgery.biomedcentral.com/articles/10.1186/s13019-023-02349-4' }
|
| 190 |
+
]
|
| 191 |
+
},
|
| 192 |
+
'Adenocarcinoma': {
|
| 193 |
+
papers: [
|
| 194 |
+
{ title: 'Adenocarcinoma Research Paper 1', url: 'https://www.ncbi.nlm.nih.gov/books/NBK562137/' },
|
| 195 |
+
{ title: 'Adenocarcinoma Research Paper 2', url: 'https://biolres.biomedcentral.com/articles/10.1186/s40659-020-00281-8' }
|
| 196 |
+
],
|
| 197 |
+
reports: [
|
| 198 |
+
{ title: 'Adenocarcinoma Case Report 1', url: 'https://hccpjournal.biomedcentral.com/articles/10.1186/1897-4287-8-S1-P4' },
|
| 199 |
+
{ title: 'Adenocarcinoma Case Report 2', url: 'https://cancerandmetabolism.biomedcentral.com/articles/10.1186/2049-3002-2-S1-P76' },
|
| 200 |
+
{ title: 'Adenocarcinoma Case Report 3', url: 'https://biologydirect.biomedcentral.com/articles/10.1186/s13062-023-00419-0' }
|
| 201 |
+
]
|
| 202 |
+
},
|
| 203 |
+
'Squamous Cell Carcinoma': {
|
| 204 |
+
papers: [
|
| 205 |
+
{ title: 'Squamous Cell Carcinoma Research Paper 1', url: 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7319751/' },
|
| 206 |
+
{ title: 'Squamous Cell Carcinoma Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/books/NBK441939/' }
|
| 207 |
+
],
|
| 208 |
+
reports: [
|
| 209 |
+
{ title: 'Squamous Cell Carcinoma Case Report 1', url: 'https://headandneckoncology.biomedcentral.com/articles/10.1186/1758-3284-1-S1-P32' },
|
| 210 |
+
{ title: 'Squamous Cell Carcinoma Case Report 2', url: 'https://headandneckoncology.biomedcentral.com/articles/10.1186/1758-3284-1-S1-P17' },
|
| 211 |
+
{ title: 'Squamous Cell Carcinoma Case Report 3', url: 'https://bmcproc.biomedcentral.com/articles/10.1186/1753-6561-7-S2-P25' }
|
| 212 |
+
]
|
| 213 |
+
},
|
| 214 |
+
'Pneumonia': {
|
| 215 |
+
papers: [
|
| 216 |
+
{ title: 'Pneumonia Research Paper 1', url: 'https://www.who.int/news-room/fact-sheets/detail/pneumonia' },
|
| 217 |
+
{ title: 'Pneumonia Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/books/NBK513321/' }
|
| 218 |
+
],
|
| 219 |
+
reports: [
|
| 220 |
+
{ title: 'Pneumonia Case Report 1', url: 'https://waojournal.biomedcentral.com/articles/10.1186/1939-4551-6-S1-P56' },
|
| 221 |
+
{ title: 'Pneumonia Case Report 2', url: 'https://ccforum.biomedcentral.com/articles/10.1186/cc12928' },
|
| 222 |
+
{ title: 'Pneumonia Case Report 3', url: 'https://waojournal.biomedcentral.com/articles/10.1186/1939-4551-6-S1-P191' }
|
| 223 |
+
]
|
| 224 |
+
}
|
| 225 |
+
// Other disease links remain the same
|
| 226 |
+
};
|
| 227 |
+
|
| 228 |
+
// JavaScript to handle tab switching
|
| 229 |
+
const tabButtons = document.querySelectorAll('.tab-button');
|
| 230 |
+
const tabContents = document.querySelectorAll('.tab-content');
|
| 231 |
+
|
| 232 |
+
tabButtons.forEach(button => {
|
| 233 |
+
button.addEventListener('click', () => {
|
| 234 |
+
tabButtons.forEach(btn => btn.classList.remove('active'));
|
| 235 |
+
tabContents.forEach(content => content.classList.remove('active'));
|
| 236 |
+
|
| 237 |
+
button.classList.add('active');
|
| 238 |
+
document.getElementById(button.dataset.target).classList.add('active');
|
| 239 |
+
});
|
| 240 |
+
});
|
| 241 |
+
|
| 242 |
+
// Function to make predictions
|
| 243 |
+
function predictDisease(diseaseType) {
|
| 244 |
+
console.log('Predicting for: ' + diseaseType); // Add this for debugging
|
| 245 |
+
let formData = new FormData(document.getElementById(diseaseType + '-form'));
|
| 246 |
+
fetch(`/predict_${diseaseType}`, {
|
| 247 |
+
method: 'POST',
|
| 248 |
+
body: formData
|
| 249 |
+
})
|
| 250 |
+
.then(response => response.json())
|
| 251 |
+
.then(data => {
|
| 252 |
+
document.getElementById(diseaseType + '-result').innerText = data.prediction;
|
| 253 |
+
populateLinks(data.prediction, diseaseType); // Pass diseaseType to populateLinks
|
| 254 |
+
})
|
| 255 |
+
.catch(error => {
|
| 256 |
+
console.error('Error:', error);
|
| 257 |
+
});
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
// Populate the research and case report links
|
| 262 |
+
function populateLinks(prediction, diseaseType) {
|
| 263 |
+
const links = researchLinks[prediction.trim()];
|
| 264 |
+
const researchLinksDiv = document.getElementById(diseaseType + '-research-links');
|
| 265 |
+
const caseReportLinksDiv = document.getElementById(diseaseType + '-case-report-links');
|
| 266 |
+
|
| 267 |
+
if (links) {
|
| 268 |
+
researchLinksDiv.innerHTML = links.papers.map(paper => `<a href="${paper.url}" target="_blank">${paper.title}</a>`).join('');
|
| 269 |
+
caseReportLinksDiv.innerHTML = links.reports.map(report => `<a href="${report.url}" target="_blank">${report.title}</a>`).join('');
|
| 270 |
+
} else {
|
| 271 |
+
researchLinksDiv.innerHTML = '<p>No research papers available for this prediction</p>';
|
| 272 |
+
caseReportLinksDiv.innerHTML = '<p>No case reports available for this prediction</p>';
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
// JavaScript function to ask the LLM
|
| 279 |
+
function askLLM() {
|
| 280 |
+
const question = document.getElementById('llm-prompt').value;
|
| 281 |
+
const answerContainer = document.getElementById('llm-answer');
|
| 282 |
+
|
| 283 |
+
fetch('/ask_llm', {
|
| 284 |
+
method: 'POST',
|
| 285 |
+
headers: {
|
| 286 |
+
'Content-Type': 'application/json',
|
| 287 |
+
},
|
| 288 |
+
body: JSON.stringify({ question: question }),
|
| 289 |
+
})
|
| 290 |
+
.then(response => response.json())
|
| 291 |
+
.then(data => {
|
| 292 |
+
answerContainer.innerHTML = `<h3>Answer: ${data.answer}</h3>`;
|
| 293 |
+
})
|
| 294 |
+
.catch(error => {
|
| 295 |
+
console.error('Error:', error);
|
| 296 |
+
answerContainer.innerHTML = '<h3>Error: Unable to fetch answer</h3>';
|
| 297 |
+
});
|
| 298 |
+
}
|
| 299 |
+
</script>
|
| 300 |
+
</body>
|
| 301 |
+
</html>
|