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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
# Set the page layout
|
| 5 |
+
st.set_page_config(layout="wide")
|
| 6 |
+
import time
|
| 7 |
+
import base64
|
| 8 |
+
import tensorflow as tf
|
| 9 |
+
import numpy as np
|
| 10 |
+
from PIL import Image
|
| 11 |
+
import torch
|
| 12 |
+
import os
|
| 13 |
+
import torch.nn as nn
|
| 14 |
+
from torchvision import transforms
|
| 15 |
+
import torch.nn.functional as F
|
| 16 |
+
|
| 17 |
+
if "model" not in st.session_state:
|
| 18 |
+
st.session_state.model = None
|
| 19 |
+
if "choice" not in st.session_state:
|
| 20 |
+
st.session_state.choice = "tensorflow"
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
#import matplotlib.pyplot as plt
|
| 24 |
+
# Path to your logo image
|
| 25 |
+
logo_path = "images/logo.png"
|
| 26 |
+
main_bg_ext = 'png'
|
| 27 |
+
main_bg = 'images/download (3).jfif'
|
| 28 |
+
#****************************************************************
|
| 29 |
+
# TENSORFLOW MODEL CONFIGURATION
|
| 30 |
+
#****************************************************************
|
| 31 |
+
class_labels=[ 'Cyst', 'Normal','Stone', 'Tumor']
|
| 32 |
+
def load_tensorflow_model():
|
| 33 |
+
# Example: Load a pre-trained model (e.g., MobileNetV2)
|
| 34 |
+
tf_model = tf.keras.models.load_model('model/best_model.keras')
|
| 35 |
+
return tf_model
|
| 36 |
+
def predict_image(image):
|
| 37 |
+
time.sleep(2)
|
| 38 |
+
image = image.resize((64, 64))
|
| 39 |
+
image = np.array(image) / 255.0
|
| 40 |
+
image = np.expand_dims(image, axis=0)
|
| 41 |
+
predictions = st.session_state.model.predict(image)
|
| 42 |
+
return predictions
|
| 43 |
+
#****************************************************************
|
| 44 |
+
# PYTORCH MODEL CONFIGURATION
|
| 45 |
+
#****************************************************************
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
class CNNModel(nn.Module):
|
| 50 |
+
def __init__(self, input_channels=3, num_classes=4):
|
| 51 |
+
super(CNNModel, self).__init__()
|
| 52 |
+
|
| 53 |
+
self.conv1 = nn.Conv2d(input_channels, 32, kernel_size=3, padding=1)
|
| 54 |
+
self.bn1 = nn.BatchNorm2d(32)
|
| 55 |
+
self.pool1 = nn.MaxPool2d(2, 2)
|
| 56 |
+
|
| 57 |
+
self.conv2 = nn.Conv2d(32, 64, kernel_size=3, padding=1)
|
| 58 |
+
self.bn2 = nn.BatchNorm2d(64)
|
| 59 |
+
self.pool2 = nn.MaxPool2d(2, 2)
|
| 60 |
+
|
| 61 |
+
self.conv3 = nn.Conv2d(64, 128, kernel_size=3, padding=1)
|
| 62 |
+
self.bn3 = nn.BatchNorm2d(128)
|
| 63 |
+
self.pool3 = nn.MaxPool2d(2, 2)
|
| 64 |
+
|
| 65 |
+
self.conv4 = nn.Conv2d(128, 256, kernel_size=3, padding=1)
|
| 66 |
+
self.bn4 = nn.BatchNorm2d(256)
|
| 67 |
+
self.pool4 = nn.MaxPool2d(2, 2)
|
| 68 |
+
|
| 69 |
+
self.flatten = nn.Flatten()
|
| 70 |
+
|
| 71 |
+
self.fc1 = nn.Linear(256 * 4 * 4, 512)
|
| 72 |
+
self.dropout1 = nn.Dropout(0.4)
|
| 73 |
+
|
| 74 |
+
self.fc2 = nn.Linear(512, 256)
|
| 75 |
+
self.dropout2 = nn.Dropout(0.3)
|
| 76 |
+
|
| 77 |
+
self.fc3 = nn.Linear(256, num_classes)
|
| 78 |
+
|
| 79 |
+
def forward(self, x):
|
| 80 |
+
x = self.pool1(torch.relu(self.bn1(self.conv1(x))))
|
| 81 |
+
x = self.pool2(torch.relu(self.bn2(self.conv2(x))))
|
| 82 |
+
x = self.pool3(torch.relu(self.bn3(self.conv3(x))))
|
| 83 |
+
x = self.pool4(torch.relu(self.bn4(self.conv4(x))))
|
| 84 |
+
|
| 85 |
+
x = self.flatten(x)
|
| 86 |
+
x = self.dropout1(torch.relu(self.fc1(x)))
|
| 87 |
+
x = self.dropout2(torch.relu(self.fc2(x)))
|
| 88 |
+
x = self.fc3(x)
|
| 89 |
+
|
| 90 |
+
return x
|
| 91 |
+
|
| 92 |
+
#*************************************************************
|
| 93 |
+
def predict_with_pytorch(image):
|
| 94 |
+
# Defining the preprocessing pipeline
|
| 95 |
+
preprocess = transforms.Compose([
|
| 96 |
+
transforms.Resize((64, 64)),
|
| 97 |
+
transforms.ToTensor(),
|
| 98 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
|
| 99 |
+
])
|
| 100 |
+
|
| 101 |
+
# Applying preprocessing transformations
|
| 102 |
+
image = preprocess(image).unsqueeze(0)
|
| 103 |
+
|
| 104 |
+
# Check if the image has the correct shape
|
| 105 |
+
print(f"Image shape after preprocessing: {image.shape}")
|
| 106 |
+
|
| 107 |
+
with torch.no_grad():
|
| 108 |
+
output = st.session_state.model(image)
|
| 109 |
+
|
| 110 |
+
probabilities = F.softmax(output, dim=1)
|
| 111 |
+
|
| 112 |
+
class_probabilities = probabilities.squeeze().tolist()
|
| 113 |
+
predicted_classes = torch.argsort(probabilities, dim=1, descending=True) #
|
| 114 |
+
|
| 115 |
+
# Return all classes and their probabilities
|
| 116 |
+
result_dict = {}
|
| 117 |
+
for idx, prob in zip(predicted_classes[0], class_probabilities):
|
| 118 |
+
result_dict[idx.item()] = prob
|
| 119 |
+
|
| 120 |
+
return result_dict
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
#**********************************************************
|
| 124 |
+
|
| 125 |
+
def load_pytorch_model():
|
| 126 |
+
# Example: Load a pre-trained model (e.g., ResNet18)
|
| 127 |
+
model = torch.load('model/torch_model.pth', map_location=torch.device('cpu')) # Forces the model to load on CPU
|
| 128 |
+
|
| 129 |
+
model.eval()
|
| 130 |
+
return model
|
| 131 |
+
#****************************************************************
|
| 132 |
+
# PYTORCH MODEL CONFIGURATION
|
| 133 |
+
#****************************************************************
|
| 134 |
+
|
| 135 |
+
# Read and encode the logo image
|
| 136 |
+
with open(logo_path, "rb") as image_file:
|
| 137 |
+
encoded_logo = base64.b64encode(image_file.read()).decode()
|
| 138 |
+
|
| 139 |
+
# Custom CSS to style the logo above the sidebar and other elements
|
| 140 |
+
st.markdown(
|
| 141 |
+
f"""
|
| 142 |
+
<style>
|
| 143 |
+
/* Container for logo and text */
|
| 144 |
+
.logo-text-container {{
|
| 145 |
+
position: fixed;
|
| 146 |
+
top: 30px; /* Adjust vertical position */
|
| 147 |
+
left: 50px; /* Align with sidebar */
|
| 148 |
+
display: flex;
|
| 149 |
+
align-items: center;
|
| 150 |
+
gap: 15px;
|
| 151 |
+
justify-content: space-between;
|
| 152 |
+
width: 100%;
|
| 153 |
+
}}
|
| 154 |
+
|
| 155 |
+
/* Logo styling */
|
| 156 |
+
.logo-text-container img {{
|
| 157 |
+
width: 130px; /* Adjust logo size */
|
| 158 |
+
border-radius: 10px; /* Optional: round edges */
|
| 159 |
+
margin-top: 10px;
|
| 160 |
+
margin-left: 20px;
|
| 161 |
+
}}
|
| 162 |
+
|
| 163 |
+
/* Bold text styling */
|
| 164 |
+
.logo-text-container h1 {{
|
| 165 |
+
font-family: 'Times New Roman', serif;
|
| 166 |
+
font-size: 24px;
|
| 167 |
+
font-weight: bold;
|
| 168 |
+
text-align: center;
|
| 169 |
+
color: #FFD700; /* Golden color for text */
|
| 170 |
+
}}
|
| 171 |
+
|
| 172 |
+
/* Sidebar styling */
|
| 173 |
+
section[data-testid="stSidebar"][aria-expanded="true"] {{
|
| 174 |
+
margin-top: 100px !important; /* Space for the logo */
|
| 175 |
+
border-radius: 0 60px 0px 60px !important; /* Top-left and bottom-right corners */
|
| 176 |
+
width: 200px !important; /* Sidebar width */
|
| 177 |
+
background: none; /* No background */
|
| 178 |
+
color: white !important;
|
| 179 |
+
}}
|
| 180 |
+
|
| 181 |
+
header[data-testid="stHeader"] {{
|
| 182 |
+
background: transparent !important;
|
| 183 |
+
margin-right: 100px !important;
|
| 184 |
+
margin-top: 1px !important;
|
| 185 |
+
z-index: 1 !important;
|
| 186 |
+
|
| 187 |
+
color: blue; /* White text */
|
| 188 |
+
font-family: "Times New Roman " !important; /* Font */
|
| 189 |
+
font-size: 18px !important; /* Font size */
|
| 190 |
+
font-weight: bold !important; /* Bold text */
|
| 191 |
+
padding: 10px 20px; /* Padding for buttons */
|
| 192 |
+
border: none; /* Remove border */
|
| 193 |
+
border-radius: 35px; /* Rounded corners */
|
| 194 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2); /* Shadow effect */
|
| 195 |
+
transition: all 0.3s ease-in-out; /* Smooth transition */
|
| 196 |
+
display: flex;
|
| 197 |
+
align-items: center;
|
| 198 |
+
justify-content: center;
|
| 199 |
+
margin: 10px 0;
|
| 200 |
+
width:90%;
|
| 201 |
+
left:5.5%;
|
| 202 |
+
height:60px;
|
| 203 |
+
margin-top:70px;
|
| 204 |
+
backdrop-filter: blur(10px);
|
| 205 |
+
border: 2px solid rgba(255, 255, 255, 0.4); /* Light border */
|
| 206 |
+
|
| 207 |
+
}}
|
| 208 |
+
|
| 209 |
+
div[data-testid="stDecoration"] {{
|
| 210 |
+
background-image: none;
|
| 211 |
+
}}
|
| 212 |
+
|
| 213 |
+
div[data-testid="stApp"] {{
|
| 214 |
+
background: url(data:image/{main_bg_ext};base64,{base64.b64encode(open(main_bg, "rb").read()).decode()});
|
| 215 |
+
background-size: cover; /* Ensure the image covers the full page */
|
| 216 |
+
background-position: center;
|
| 217 |
+
height: 98vh;
|
| 218 |
+
width: 98%;
|
| 219 |
+
border-radius: 20px !important;
|
| 220 |
+
margin-left: 10px;
|
| 221 |
+
margin-right: 10px;
|
| 222 |
+
margin-top: 10px;
|
| 223 |
+
overflow: hidden;
|
| 224 |
+
backdrop-filter: blur(10px); /* Glass effect */
|
| 225 |
+
-webkit-backdrop-filter: blur(10px);
|
| 226 |
+
border: 1px solid rgba(255, 255, 255, 0.2); /* Light border */
|
| 227 |
+
|
| 228 |
+
}}
|
| 229 |
+
|
| 230 |
+
div[data-testid="stSidebarNav"] {{
|
| 231 |
+
display: none;
|
| 232 |
+
}}
|
| 233 |
+
|
| 234 |
+
/* Styling for the content container */
|
| 235 |
+
[class*="st-key-content-container-1"] {{
|
| 236 |
+
|
| 237 |
+
background: rgba(255, 255, 255, 0.5); /* Semi-transparent white background */
|
| 238 |
+
border: 2px solid rgba(255, 255, 255, 0.4); /* Light border */
|
| 239 |
+
|
| 240 |
+
backdrop-filter: blur(10px); /* Apply blur effect */
|
| 241 |
+
-webkit-backdrop-filter: blur(10px); /* For Safari compatibility */
|
| 242 |
+
border-radius: 20px;
|
| 243 |
+
padding: 20px;
|
| 244 |
+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
|
| 245 |
+
width: 98%; /* Make it span across most of the screen */
|
| 246 |
+
margin-left: 0.5%;
|
| 247 |
+
margin-right: 0.5%;
|
| 248 |
+
height: 92.5vh; /* Adjust to fill most of the screen */
|
| 249 |
+
overflow-y: auto; /* Enable vertical scrolling */
|
| 250 |
+
position: fixed; /* Keep the container fixed on the screen */
|
| 251 |
+
top: 3.5%; /* Adjust top margin */
|
| 252 |
+
left: 0.5%; /* Adjust left margin */
|
| 253 |
+
z-index: 0; /* Keep behind sidebar and header */
|
| 254 |
+
margin-bottom:2%;
|
| 255 |
+
|
| 256 |
+
}}
|
| 257 |
+
[class*="st-key-content-container-3"] {{
|
| 258 |
+
|
| 259 |
+
width: 28%; /* Make it span across most of the screen */
|
| 260 |
+
position:fixed;
|
| 261 |
+
top: -0.9%; /* Adjust top margin */
|
| 262 |
+
left: 11%; /* Adjust left margin */
|
| 263 |
+
z-index: 1; /* Keep behind sidebar and header */
|
| 264 |
+
padding-left:20px;
|
| 265 |
+
align-item:center;
|
| 266 |
+
border: 2px solid rgba(255, 255, 255, 0.4); /* Light border */
|
| 267 |
+
background: transparent !important;
|
| 268 |
+
margin-right: 100px !important;
|
| 269 |
+
border-right: 2px solid rgba(255, 255, 155, 0.4); /* Light border */
|
| 270 |
+
|
| 271 |
+
z-index: 1 !important;
|
| 272 |
+
|
| 273 |
+
color: blue; /* White text */
|
| 274 |
+
font-family: "Times New Roman " !important; /* Font */
|
| 275 |
+
font-size: 18px !important; /* Font size */
|
| 276 |
+
font-weight: bold !important; /* Bold text */
|
| 277 |
+
padding: 10px 20px; /* Padding for buttons */
|
| 278 |
+
border: none; /* Remove border */
|
| 279 |
+
border-radius: 35px; /* Rounded corners */
|
| 280 |
+
transition: all 0.3s ease-in-out; /* Smooth transition */
|
| 281 |
+
display: flex;
|
| 282 |
+
align-items: center;
|
| 283 |
+
justify-content: center;
|
| 284 |
+
margin: 10px 0;
|
| 285 |
+
|
| 286 |
+
height:60px;
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
|
| 291 |
+
}}
|
| 292 |
+
/* Styling for the content container */
|
| 293 |
+
[class*="st-key-content-container-2"] {{
|
| 294 |
+
background-color: transparent; /* Transparent background */
|
| 295 |
+
border-radius: 20px;
|
| 296 |
+
padding: 20px;
|
| 297 |
+
width: 50%; /* Make it span across most of the screen */
|
| 298 |
+
|
| 299 |
+
height: 85vh; /* Adjust to fill most of the screen */
|
| 300 |
+
overflow-y: auto; /* Enable vertical scrolling */
|
| 301 |
+
position: fixed; /* Keep the container fixed on the screen */
|
| 302 |
+
top: 7%; /* Adjust top margin */
|
| 303 |
+
left: 49.5%; /* Adjust left margin */
|
| 304 |
+
right:2%;
|
| 305 |
+
border-left: 3px solid rgba(255, 255, 155, 0.9); /* Light border */
|
| 306 |
+
|
| 307 |
+
}}
|
| 308 |
+
|
| 309 |
+
/* Button row styling */
|
| 310 |
+
.button-row {{
|
| 311 |
+
display: flex;
|
| 312 |
+
justify-content: flex-start;
|
| 313 |
+
gap: 20px;
|
| 314 |
+
margin-bottom: 20px;
|
| 315 |
+
}}
|
| 316 |
+
|
| 317 |
+
.custom-button {{
|
| 318 |
+
width: 100px;
|
| 319 |
+
height: 40px;
|
| 320 |
+
border-radius: 10px;
|
| 321 |
+
background-color: #007BFF;
|
| 322 |
+
color: white;
|
| 323 |
+
border: none;
|
| 324 |
+
cursor: pointer;
|
| 325 |
+
font-size: 16px;
|
| 326 |
+
}}
|
| 327 |
+
|
| 328 |
+
.custom-button:hover {{
|
| 329 |
+
background-color: #0056b3;
|
| 330 |
+
}}
|
| 331 |
+
div.stButton > button {{
|
| 332 |
+
background: rgba(255, 255, 255, 0.2);
|
| 333 |
+
color: blue; /* White text */
|
| 334 |
+
font-family: "Times New Roman " !important; /* Font */
|
| 335 |
+
font-size: 18px !important; /* Font size */
|
| 336 |
+
font-weight: bold !important; /* Bold text */
|
| 337 |
+
padding: 10px 20px; /* Padding for buttons */
|
| 338 |
+
border: none; /* Remove border */
|
| 339 |
+
border-radius: 35px; /* Rounded corners */
|
| 340 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2); /* Shadow effect */
|
| 341 |
+
transition: all 0.3s ease-in-out; /* Smooth transition */
|
| 342 |
+
display: flex;
|
| 343 |
+
align-items: center;
|
| 344 |
+
justify-content: center;
|
| 345 |
+
margin: 10px 0;
|
| 346 |
+
width:160px;
|
| 347 |
+
height:50px;
|
| 348 |
+
margin-top:5px;
|
| 349 |
+
|
| 350 |
+
}}
|
| 351 |
+
|
| 352 |
+
/* Hover effect */
|
| 353 |
+
div.stButton > button:hover {{
|
| 354 |
+
background: rgba(255, 255, 255, 0.2);
|
| 355 |
+
box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.4); /* Enhanced shadow on hover */
|
| 356 |
+
transform: scale(1.05); /* Slightly enlarge button */
|
| 357 |
+
transform: scale(1.1); /* Slight zoom on hover */
|
| 358 |
+
box-shadow: 0px 4px 12px rgba(255, 255, 255, 0.4); /* Glow effect */
|
| 359 |
+
}}
|
| 360 |
+
/* Outer large circle with transparent background */
|
| 361 |
+
.outer-circle {{
|
| 362 |
+
width: 350px;
|
| 363 |
+
height: 350px;
|
| 364 |
+
border-radius: 40%; /* Circular shape */
|
| 365 |
+
background-color: transparent; /* Transparent background */
|
| 366 |
+
border: 1px solid white; /* Golden border */
|
| 367 |
+
display: flex;
|
| 368 |
+
justify-content: center;
|
| 369 |
+
align-items: center;
|
| 370 |
+
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); /* Shadow for depth */
|
| 371 |
+
}}
|
| 372 |
+
|
| 373 |
+
/* Inner smaller circle with light grey background */
|
| 374 |
+
.inner-circle {{
|
| 375 |
+
width: 330px;
|
| 376 |
+
height: 330px;
|
| 377 |
+
backdrop-filter: blur(10px);
|
| 378 |
+
background: rgba(255, 255, 255, 0.2);
|
| 379 |
+
|
| 380 |
+
border-radius: 40%; /* Circular shape */
|
| 381 |
+
display: flex;
|
| 382 |
+
justify-content: center;
|
| 383 |
+
align-items: center;
|
| 384 |
+
overflow: hidden; /* Ensure image is contained within the circle */
|
| 385 |
+
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4); /* Shadow for depth */
|
| 386 |
+
border: 1px solid white; /* Golden border */
|
| 387 |
+
|
| 388 |
+
}}
|
| 389 |
+
|
| 390 |
+
/* Style for the image to fit within the inner circle */
|
| 391 |
+
.inner-circle img {{
|
| 392 |
+
width: 100%;
|
| 393 |
+
height: 100%;
|
| 394 |
+
object-fit: cover; /* Ensure the image covers the circular area */
|
| 395 |
+
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); /* Shadow for depth */
|
| 396 |
+
|
| 397 |
+
}}
|
| 398 |
+
/* Style for the upload button */
|
| 399 |
+
[class*="st-key-upload-btn"] {{
|
| 400 |
+
position: absolute;
|
| 401 |
+
top: 50%; /* Position from the top of the inner circle */
|
| 402 |
+
left: 5%; /* Position horizontally at the center */
|
| 403 |
+
transform: translateX(-40%); /* Adjust to ensure it's centered */
|
| 404 |
+
padding: 10px 20px;
|
| 405 |
+
color: black;
|
| 406 |
+
border: none;
|
| 407 |
+
border-radius: 20px;
|
| 408 |
+
cursor: pointer;
|
| 409 |
+
font-size: 23px;
|
| 410 |
+
with:300px;
|
| 411 |
+
height:100px;
|
| 412 |
+
z-index:1000;
|
| 413 |
+
}}
|
| 414 |
+
|
| 415 |
+
.upload-btn:hover {{
|
| 416 |
+
background-color: rgba(0, 123, 255, 1);
|
| 417 |
+
}}
|
| 418 |
+
div[data-testid="stFileUploader"] label > div > p {{
|
| 419 |
+
display:none;
|
| 420 |
+
color:white !important;
|
| 421 |
+
}}
|
| 422 |
+
section[data-testid="stFileUploaderDropzone"] {{
|
| 423 |
+
width:190px;
|
| 424 |
+
height: 120px;
|
| 425 |
+
background-color: white;
|
| 426 |
+
border-radius: 40px;
|
| 427 |
+
display: flex;
|
| 428 |
+
justify-content: center;
|
| 429 |
+
align-items: center;
|
| 430 |
+
margin-top:-10px;
|
| 431 |
+
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
|
| 432 |
+
margin:20px;
|
| 433 |
+
background-color: rgba(255, 255, 255, 0.7); /* Transparent blue background */
|
| 434 |
+
color:white;
|
| 435 |
+
}}
|
| 436 |
+
div[data-testid="stFileUploaderDropzoneInstructions"] div > small{{
|
| 437 |
+
color:white !important;
|
| 438 |
+
display:none;
|
| 439 |
+
}}
|
| 440 |
+
div[data-testid="stFileUploaderDropzoneInstructions"] span{{
|
| 441 |
+
margin-left:60px;
|
| 442 |
+
}}
|
| 443 |
+
div[data-testid="stFileUploaderDropzoneInstructions"] div{{
|
| 444 |
+
display:none;
|
| 445 |
+
}}
|
| 446 |
+
section[data-testid="stFileUploaderDropzone"] button{{
|
| 447 |
+
display:none;
|
| 448 |
+
}}
|
| 449 |
+
div[data-testid="stMarkdownContainer"] p {{
|
| 450 |
+
font-family: "Times New Roman" !important; /* Elegant font for title */
|
| 451 |
+
color:white !important;
|
| 452 |
+
}}
|
| 453 |
+
.title {{
|
| 454 |
+
font-family: "Times New Roman" !important; /* Elegant font for title */
|
| 455 |
+
font-size: 1.rem;
|
| 456 |
+
font-weight: bold;
|
| 457 |
+
margin-left: 37px;
|
| 458 |
+
margin-top:10px;
|
| 459 |
+
margin-bottom:-100px;
|
| 460 |
+
padding: 0;
|
| 461 |
+
color: #333; /* Neutral color for text */
|
| 462 |
+
}}
|
| 463 |
+
|
| 464 |
+
</style>
|
| 465 |
+
|
| 466 |
+
""",
|
| 467 |
+
unsafe_allow_html=True,
|
| 468 |
+
)
|
| 469 |
+
st.markdown(
|
| 470 |
+
"""
|
| 471 |
+
<style>
|
| 472 |
+
/* Outer container to define the grid */
|
| 473 |
+
.grid-container {
|
| 474 |
+
display: grid;
|
| 475 |
+
grid-template-columns: repeat(2 1fr); /* 2 columns */
|
| 476 |
+
grid-template-rows: repeat(2, 1fr); /* 2 rows */
|
| 477 |
+
gap: 20px; /* Space between containers */
|
| 478 |
+
width: 90%;
|
| 479 |
+
height: 5vh;
|
| 480 |
+
align-items: center;
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
/* Individual grid items (containers) */
|
| 484 |
+
.grid-item {
|
| 485 |
+
padding: 20px;
|
| 486 |
+
border-radius: 10px;
|
| 487 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
| 488 |
+
display: flex;
|
| 489 |
+
justify-content: left;
|
| 490 |
+
align-items: center;
|
| 491 |
+
text-align: left;
|
| 492 |
+
background: rgba(0, 0, 0, 0.2); /* Semi-transparent white background */
|
| 493 |
+
|
| 494 |
+
border-radius: 20px;
|
| 495 |
+
padding: 20px;
|
| 496 |
+
width: 80%; /* Make it span across most of the screen */
|
| 497 |
+
margin-left: 0.5%;
|
| 498 |
+
margin-right: 0.5%;
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
/* Optional styling for the subheader and content */
|
| 502 |
+
.grid-item h3 {
|
| 503 |
+
margin: 0;
|
| 504 |
+
color: #333;
|
| 505 |
+
font-size:18px;
|
| 506 |
+
width:100px;
|
| 507 |
+
font-family: "Times New Roman" !important; /* Elegant font for title */
|
| 508 |
+
font-size: 1.rem;
|
| 509 |
+
font-weight: bold;
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
.grid-item p {
|
| 513 |
+
color: #555;
|
| 514 |
+
}
|
| 515 |
+
.title-container {
|
| 516 |
+
display: flex;
|
| 517 |
+
align-items: center; /* Vertically center the title and the image */
|
| 518 |
+
}
|
| 519 |
+
.title-container img {
|
| 520 |
+
width: 40px; /* Adjust the size of the image */
|
| 521 |
+
height: 40px; /* Adjust the size of the image */
|
| 522 |
+
margin-right: 10px; /* Space between the image and the title */
|
| 523 |
+
}
|
| 524 |
+
.title {
|
| 525 |
+
font-size: 20px;
|
| 526 |
+
font-weight: bold;
|
| 527 |
+
}
|
| 528 |
+
</style>
|
| 529 |
+
""", unsafe_allow_html=True
|
| 530 |
+
)
|
| 531 |
+
|
| 532 |
+
|
| 533 |
+
|
| 534 |
+
|
| 535 |
+
|
| 536 |
+
|
| 537 |
+
# Create the main content area
|
| 538 |
+
with st.container(key="content-container-3"):
|
| 539 |
+
col1,_, col2 = st.columns([2,4, 2])
|
| 540 |
+
with col1:
|
| 541 |
+
if st.button(" Tensorflow"):
|
| 542 |
+
st.session_state.model = load_tensorflow_model()
|
| 543 |
+
st.session_state.choice = "tensorflow"
|
| 544 |
+
with col2:
|
| 545 |
+
if st.button(" Pytorch"):
|
| 546 |
+
st.session_state.model = load_pytorch_model()
|
| 547 |
+
st.session_state.choice = "pytorch"
|
| 548 |
+
with st.container(key="content-container-1"):
|
| 549 |
+
|
| 550 |
+
image_path = "images/t.jpg"
|
| 551 |
+
col1, col2 = st.columns([1, 9])
|
| 552 |
+
with col1:
|
| 553 |
+
st.write("")
|
| 554 |
+
|
| 555 |
+
with col2:
|
| 556 |
+
st.write("")
|
| 557 |
+
if st.session_state.choice == "tensorflow":
|
| 558 |
+
st.markdown(f""" <div class="title-container">
|
| 559 |
+
<img src="data:image/png;base64,{base64.b64encode(open("images/tensorflow.png","rb").read()).decode()}" alt="Uploaded Image">
|
| 560 |
+
<h2 class="title">Tensorflow Model Information</h2></div>""", unsafe_allow_html=True)
|
| 561 |
+
st.write("This is a Convolutional Neural Network (CNN) model trained on image data.")
|
| 562 |
+
st.write(f"Input Shape: (64, 64, 3)")
|
| 563 |
+
st.write(f"Output Classes: {4} classes")
|
| 564 |
+
else :
|
| 565 |
+
st.markdown(f""" <div class="title-container">
|
| 566 |
+
<img src="data:image/png;base64,{base64.b64encode(open("images/pytorch.png","rb").read()).decode()}" alt="Uploaded Image">
|
| 567 |
+
<h2 class="title">Pytorch Model Information</h2></div>""", unsafe_allow_html=True)
|
| 568 |
+
st.write("This is a Convolutional Neural Network (CNN) model trained on image data.")
|
| 569 |
+
st.write(f"Input Shape: (64, 64, 3)")
|
| 570 |
+
st.write(f"Output Classes: {4} classes")
|
| 571 |
+
|
| 572 |
+
col3, col4 = st.columns([3, 7])
|
| 573 |
+
with col3:
|
| 574 |
+
uploaded_file = st.file_uploader("Choose a file", type=["png", "jpg", "jpeg"],key="upload-btn")
|
| 575 |
+
if uploaded_file is not None:
|
| 576 |
+
|
| 577 |
+
|
| 578 |
+
with open(image_path, "rb") as image_file:
|
| 579 |
+
encoded_image = base64.b64encode(image_file.read()).decode()
|
| 580 |
+
|
| 581 |
+
# Display the circular container with the image inside
|
| 582 |
+
st.markdown(
|
| 583 |
+
f"""
|
| 584 |
+
<div class="outer-circle">
|
| 585 |
+
<div class="inner-circle">
|
| 586 |
+
<img src="data:image/png;base64,{base64.b64encode(uploaded_file.read()).decode()}" alt="Uploaded Image">
|
| 587 |
+
|
| 588 |
+
</div>
|
| 589 |
+
|
| 590 |
+
</div>
|
| 591 |
+
""",
|
| 592 |
+
unsafe_allow_html=True,
|
| 593 |
+
)
|
| 594 |
+
else:
|
| 595 |
+
default_image_path = "images/t.jpg"
|
| 596 |
+
with open(default_image_path, "rb") as image_file:
|
| 597 |
+
encoded_image = base64.b64encode(image_file.read()).decode()
|
| 598 |
+
|
| 599 |
+
|
| 600 |
+
# Display the circular container with the image inside
|
| 601 |
+
st.markdown(
|
| 602 |
+
f"""
|
| 603 |
+
<div class="outer-circle">
|
| 604 |
+
<div class="inner-circle">
|
| 605 |
+
<img src="data:image/png;base64,{encoded_image}" alt="Default Image">
|
| 606 |
+
|
| 607 |
+
</div>
|
| 608 |
+
|
| 609 |
+
</div>
|
| 610 |
+
""",
|
| 611 |
+
unsafe_allow_html=True,
|
| 612 |
+
)
|
| 613 |
+
|
| 614 |
+
with col4:
|
| 615 |
+
with st.container(key="content-container-2"):
|
| 616 |
+
if uploaded_file != None:
|
| 617 |
+
images = Image.open(uploaded_file)
|
| 618 |
+
|
| 619 |
+
with st.spinner("Processing the image..."):
|
| 620 |
+
|
| 621 |
+
progress_bar = st.progress(0)
|
| 622 |
+
for i in range(1, 11):
|
| 623 |
+
|
| 624 |
+
time.sleep(0.6) # Simulated delay for each progress increment
|
| 625 |
+
progress_bar.progress(i * 10)
|
| 626 |
+
|
| 627 |
+
|
| 628 |
+
if st.session_state.choice == "tensorflow":
|
| 629 |
+
prediction = predict_image(images)
|
| 630 |
+
max_index = int(np.argmax(prediction[0]))
|
| 631 |
+
max_score = prediction[0][max_index]
|
| 632 |
+
descriptive_message = ""
|
| 633 |
+
if max_index == 0:
|
| 634 |
+
descriptive_message = f"""
|
| 635 |
+
This image is likely to represent a <b>{class_labels[max_index]} kideney</b> ,which is an indication of healthy tissue with no signs of abnormal growth.
|
| 636 |
+
We recommend maintaining a healthy lifestyle and continuing regular health check-ups to ensure the body remains in a natural, healthy state.
|
| 637 |
+
"""
|
| 638 |
+
elif max_index == 1:
|
| 639 |
+
descriptive_message = f"""
|
| 640 |
+
This image is likely to represent a <b>{class_labels[max_index]} kideney</b>, which is a fluid-filled sac that forms in various body parts.
|
| 641 |
+
Cysts are typically benign and may not require treatment unless they grow large or become infected. We recommend monitoring the cyst and consulting a healthcare provider if you notice any changes.
|
| 642 |
+
"""
|
| 643 |
+
elif max_index == 2:
|
| 644 |
+
descriptive_message = f"""
|
| 645 |
+
This image is likely to represent a <b>{class_labels[max_index]} kideney</b>, which is a solid mass that forms in organs like the kidneys or bladder due to crystallization of minerals or salts.
|
| 646 |
+
Stones can be painful, and treatment may include passing them naturally or removing them surgically. We recommend staying hydrated and avoiding excessive salt intake to prevent stones from forming.
|
| 647 |
+
"""
|
| 648 |
+
else:
|
| 649 |
+
descriptive_message = f"""
|
| 650 |
+
This image is likely to represent a <b>{class_labels[max_index]} kideney</b>, which is an abnormal growth of tissue. Tumors can be benign or malignant, and further testing is required to determine the exact nature.
|
| 651 |
+
We recommend consulting a healthcare provider for further investigation and treatment if necessary.
|
| 652 |
+
"""
|
| 653 |
+
|
| 654 |
+
if prediction is not None and len(prediction) > 0: # Check if prediction is valid
|
| 655 |
+
divs = f"""
|
| 656 |
+
<div class="grid-container">
|
| 657 |
+
<div class="grid-item">
|
| 658 |
+
<h3>{class_labels[0]}</h3>
|
| 659 |
+
<p>T Score: {prediction[0][0]:.2f}</p>
|
| 660 |
+
</div>
|
| 661 |
+
<div class="grid-item">
|
| 662 |
+
<h3> {class_labels[1]}</h3>
|
| 663 |
+
<p>T Score: {prediction[0][1]:.2f}</p>
|
| 664 |
+
</div>
|
| 665 |
+
<div class="grid-item">
|
| 666 |
+
<h3> {class_labels[2]}</h3>
|
| 667 |
+
<p>T Score: {prediction[0][2]:.2f}</p>
|
| 668 |
+
</div>
|
| 669 |
+
<div class="grid-item">
|
| 670 |
+
<h3>{class_labels[3]}</h3>
|
| 671 |
+
<p>T Score: {prediction[0][3]:.2f}</p>
|
| 672 |
+
</div>
|
| 673 |
+
<h2 class = "title">Prediction: {class_labels[max_index]} with confidence {prediction[0][max_index]:.2f}</h2>
|
| 674 |
+
<p>{descriptive_message}</p>
|
| 675 |
+
</div>
|
| 676 |
+
"""
|
| 677 |
+
|
| 678 |
+
st.markdown(divs, unsafe_allow_html=True)
|
| 679 |
+
|
| 680 |
+
else :
|
| 681 |
+
predictions = predict_with_pytorch(images)
|
| 682 |
+
predictiont =list( predictions.keys())
|
| 683 |
+
|
| 684 |
+
predicted_index = max(predictions, key=predictions.get)
|
| 685 |
+
print(f"classe {predictions}")
|
| 686 |
+
print(f"classes {predicted_index}")
|
| 687 |
+
descriptive_message = ""
|
| 688 |
+
if predicted_index == 0:
|
| 689 |
+
descriptive_message = f"""
|
| 690 |
+
This image is likely to represent a <b>{class_labels[predicted_index]} kideney</b>, which is an indication of healthy tissue with no signs of abnormal growth.
|
| 691 |
+
We recommend maintaining a healthy lifestyle and continuing regular health check-ups to ensure the body remains in a natural, healthy state.
|
| 692 |
+
"""
|
| 693 |
+
elif predicted_index == 1:
|
| 694 |
+
descriptive_message = f"""
|
| 695 |
+
This image is likely to represent a <b>{class_labels[predicted_index]} kideney</b>, which is a fluid-filled sac that forms in various body parts.
|
| 696 |
+
Cysts are typically benign and may not require treatment unless they grow large or become infected. We recommend monitoring the cyst and consulting a healthcare provider if you notice any changes.
|
| 697 |
+
"""
|
| 698 |
+
elif predicted_index == 2:
|
| 699 |
+
descriptive_message = f"""
|
| 700 |
+
This image is likely to represent a <b>{class_labels[predicted_index]} kideney</b>, which is a solid mass that forms in organs like the kidneys or bladder due to crystallization of minerals or salts.
|
| 701 |
+
Stones can be painful, and treatment may include passing them naturally or removing them surgically. We recommend staying hydrated and avoiding excessive salt intake to prevent stones from forming.
|
| 702 |
+
"""
|
| 703 |
+
else:
|
| 704 |
+
descriptive_message = f"""
|
| 705 |
+
This image is likely to represent a <b>{class_labels[predicted_index]} kideney</b>, which is an abnormal growth of tissue. Tumors can be benign or malignant, and further testing is required to determine the exact nature.
|
| 706 |
+
We recommend consulting a healthcare provider for further investigation and treatment if necessary.
|
| 707 |
+
"""
|
| 708 |
+
|
| 709 |
+
# Once preprocessing is done, show the content (grid in your case)
|
| 710 |
+
if predictiont:
|
| 711 |
+
st.markdown(f"""
|
| 712 |
+
<div class="grid-container">
|
| 713 |
+
<div class="grid-item">
|
| 714 |
+
<h3>{class_labels[predictiont[0]]} </h3>
|
| 715 |
+
<p>T Score: {predictions[predictiont[0]]:.2f}</p>
|
| 716 |
+
</div>
|
| 717 |
+
<div class="grid-item">
|
| 718 |
+
<h3>{class_labels[predictiont[1]]} </h3>
|
| 719 |
+
<p>T Score: {predictions[predictiont[1]]:.2f}</p>
|
| 720 |
+
</div>
|
| 721 |
+
<div class="grid-item">
|
| 722 |
+
<h3> {class_labels[predictiont[2]]} </h3>
|
| 723 |
+
<p>T Score: {predictions[predictiont[2]]:.2f}</p>
|
| 724 |
+
</div>
|
| 725 |
+
<div class="grid-item">
|
| 726 |
+
<h3>{class_labels[predictiont[3]]} </h3>
|
| 727 |
+
<p>T Score: {predictions[predictiont[3]]:.2f}</p>
|
| 728 |
+
</div>
|
| 729 |
+
<h2 class = "title">Prediction: {class_labels[predicted_index]} with confidence {predictions[predicted_index]:.2f}</h2>
|
| 730 |
+
<p>{descriptive_message}</p>
|
| 731 |
+
</div>
|
| 732 |
+
""", unsafe_allow_html=True
|
| 733 |
+
)
|
| 734 |
+
|
| 735 |
+
|
| 736 |
+
|
| 737 |
+
|