Spaces:
Sleeping
Sleeping
Delete web/analyzer_new.html
Browse files- web/analyzer_new.html +0 -344
web/analyzer_new.html
DELETED
|
@@ -1,344 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8" />
|
| 5 |
-
<title>Document Analyzer | CTRL + ALT + HEAL</title>
|
| 6 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
-
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
-
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet" />
|
| 9 |
-
<style>
|
| 10 |
-
:root {
|
| 11 |
-
--tropical-indigo: rgb(120, 187, 242);
|
| 12 |
-
--wisteria: rgb(197, 217, 251);
|
| 13 |
-
--latte-cream: #ffffff;
|
| 14 |
-
}
|
| 15 |
-
|
| 16 |
-
body {
|
| 17 |
-
font-family: "Rubik", sans-serif;
|
| 18 |
-
background-color: var(--latte-cream);
|
| 19 |
-
color: #333;
|
| 20 |
-
}
|
| 21 |
-
|
| 22 |
-
.btn-primary {
|
| 23 |
-
background-color: var(--tropical-indigo);
|
| 24 |
-
color: white;
|
| 25 |
-
transition: 0.3s;
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
.btn-primary:hover {
|
| 29 |
-
background-color: var(--wisteria);
|
| 30 |
-
color: #333;
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
.rec-card {
|
| 34 |
-
background-color: var(--wisteria);
|
| 35 |
-
border: 1px solid #d1d5db;
|
| 36 |
-
border-radius: 1rem;
|
| 37 |
-
padding: 1.25rem;
|
| 38 |
-
margin-bottom: 1.5rem;
|
| 39 |
-
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
|
| 40 |
-
transition: all 0.3s;
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
-
.rec-card:hover {
|
| 44 |
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
|
| 45 |
-
transform: scale(1.01);
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
.rec-title {
|
| 49 |
-
font-size: 1.125rem;
|
| 50 |
-
font-weight: 700;
|
| 51 |
-
color: var(--tropical-indigo);
|
| 52 |
-
margin-bottom: 0.5rem;
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
.rec-badge {
|
| 56 |
-
font-size: 0.75rem;
|
| 57 |
-
font-weight: 600;
|
| 58 |
-
padding: 0.25rem 0.75rem;
|
| 59 |
-
border-radius: 9999px;
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
-
.badge-high {
|
| 63 |
-
color: rgb(255, 132, 132);
|
| 64 |
-
}
|
| 65 |
-
|
| 66 |
-
.badge-medium {
|
| 67 |
-
color: rgb(253, 231, 171);
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
.badge-low {
|
| 71 |
-
color: rgb(168, 255, 172);
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
.rec-content {
|
| 75 |
-
list-style-type: disc;
|
| 76 |
-
margin-left: 1.25rem;
|
| 77 |
-
font-size: 0.875rem;
|
| 78 |
-
color: #333;
|
| 79 |
-
}
|
| 80 |
-
|
| 81 |
-
.rec-link {
|
| 82 |
-
color: var(--tropical-indigo);
|
| 83 |
-
text-decoration: underline;
|
| 84 |
-
transition: color 0.2s;
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
.rec-link:hover {
|
| 88 |
-
color: #5a99c9;
|
| 89 |
-
}
|
| 90 |
-
</style>
|
| 91 |
-
</head>
|
| 92 |
-
<body>
|
| 93 |
-
<!-- Navbar -->
|
| 94 |
-
<nav class="bg-var(--latte-cream) shadow px-6 py-4">
|
| 95 |
-
<div class="container mx-auto flex justify-between items-center">
|
| 96 |
-
<a
|
| 97 |
-
href="index.html"
|
| 98 |
-
class="text-2xl font-bold"
|
| 99 |
-
style="color: var(--tropical-indigo)"
|
| 100 |
-
>CTRL + ALT + HEAL</a
|
| 101 |
-
>
|
| 102 |
-
<ul class="flex space-x-6 text-sm font-medium">
|
| 103 |
-
<li>
|
| 104 |
-
<a
|
| 105 |
-
href="index.html"
|
| 106 |
-
style="color: #333"
|
| 107 |
-
class="hover:text-var(--tropical-indigo)"
|
| 108 |
-
>Home</a
|
| 109 |
-
>
|
| 110 |
-
</li>
|
| 111 |
-
<li>
|
| 112 |
-
<a
|
| 113 |
-
href="analyzer.html"
|
| 114 |
-
style="color: #333"
|
| 115 |
-
class="hover:text-var(--tropical-indigo)"
|
| 116 |
-
>Analyzer</a
|
| 117 |
-
>
|
| 118 |
-
</li>
|
| 119 |
-
<li>
|
| 120 |
-
<a
|
| 121 |
-
href="profile.html"
|
| 122 |
-
style="color: #333"
|
| 123 |
-
class="hover:text-var(--tropical-indigo)"
|
| 124 |
-
>Profile</a
|
| 125 |
-
>
|
| 126 |
-
</li>
|
| 127 |
-
<li>
|
| 128 |
-
<a
|
| 129 |
-
href="login.html"
|
| 130 |
-
style="color: #333"
|
| 131 |
-
class="hover:text-var(--tropical-indigo)"
|
| 132 |
-
>Login</a
|
| 133 |
-
>
|
| 134 |
-
</li>
|
| 135 |
-
<li>
|
| 136 |
-
<a
|
| 137 |
-
href="about.html"
|
| 138 |
-
style="color: #333"
|
| 139 |
-
class="hover:text-var(--tropical-indigo)"
|
| 140 |
-
>About Us</a
|
| 141 |
-
>
|
| 142 |
-
</li>
|
| 143 |
-
</ul>
|
| 144 |
-
</div>
|
| 145 |
-
</nav>
|
| 146 |
-
|
| 147 |
-
<main class="max-w-5xl mx-auto px-4 mb-16 pt-4">
|
| 148 |
-
<!-- Upload Section -->
|
| 149 |
-
<div class="bg-var(--latte-cream) shadow rounded-lg p-6 mb-8">
|
| 150 |
-
<h2
|
| 151 |
-
class="text-xl font-semibold mb-4"
|
| 152 |
-
style="color: var(--tropical-indigo)"
|
| 153 |
-
>
|
| 154 |
-
Upload & Analyze Your Medical PDF or Image
|
| 155 |
-
</h2>
|
| 156 |
-
<input
|
| 157 |
-
type="file"
|
| 158 |
-
id="pdf-upload"
|
| 159 |
-
accept=".pdf, image/*"
|
| 160 |
-
class="w-full mb-4 border border-gray-300 rounded px-3 py-2"
|
| 161 |
-
/>
|
| 162 |
-
<button id="analyze-btn" class="btn-primary px-4 py-2 rounded">
|
| 163 |
-
Analyze with AI
|
| 164 |
-
</button>
|
| 165 |
-
<p id="loading" class="text-gray-600 mt-2">No file uploaded yet.</p>
|
| 166 |
-
</div>
|
| 167 |
-
|
| 168 |
-
<!-- Summary Box -->
|
| 169 |
-
<div class="bg-var(--latte-cream) shadow rounded-lg p-6 mb-8">
|
| 170 |
-
<h3
|
| 171 |
-
class="text-lg font-semibold mb-3"
|
| 172 |
-
style="color: var(--tropical-indigo)"
|
| 173 |
-
>
|
| 174 |
-
Summarized Text
|
| 175 |
-
</h3>
|
| 176 |
-
<div
|
| 177 |
-
class="whitespace-pre-wrap h-60 overflow-y-auto bg-var(--latte-cream) text-sm border border-gray-200 rounded p-4"
|
| 178 |
-
id="summaryBox"
|
| 179 |
-
>
|
| 180 |
-
...
|
| 181 |
-
</div>
|
| 182 |
-
</div>
|
| 183 |
-
|
| 184 |
-
<!-- AI Recommendations -->
|
| 185 |
-
<div class="bg-var(--latte-cream) shadow rounded-lg p-6 mb-8">
|
| 186 |
-
<h3
|
| 187 |
-
class="text-lg font-semibold mb-3"
|
| 188 |
-
style="color: var(--tropical-indigo)"
|
| 189 |
-
>
|
| 190 |
-
AI Recommendations
|
| 191 |
-
</h3>
|
| 192 |
-
<div id="recommendations-output" class="space-y-4"></div>
|
| 193 |
-
</div>
|
| 194 |
-
|
| 195 |
-
<!-- Chatbot Section -->
|
| 196 |
-
<div class="bg-var(--latte-cream) shadow rounded-lg p-6">
|
| 197 |
-
<h3
|
| 198 |
-
class="text-lg font-semibold mb-3"
|
| 199 |
-
style="color: var(--tropical-indigo)"
|
| 200 |
-
>
|
| 201 |
-
Ask Dr. CTRL
|
| 202 |
-
</h3>
|
| 203 |
-
<div
|
| 204 |
-
id="chat-output"
|
| 205 |
-
class="space-y-2 h-48 overflow-y-auto border border-gray-200 rounded p-4"
|
| 206 |
-
style="background-color: var(--wisteria); color: #333"
|
| 207 |
-
>
|
| 208 |
-
<p>
|
| 209 |
-
<strong>Dr. CTRL:</strong> Hello, I’m Dr. CTRL — your pixel-powered
|
| 210 |
-
digital doctor. Let’s get you healed up, one byte at a time.
|
| 211 |
-
</p>
|
| 212 |
-
</div>
|
| 213 |
-
<div class="flex mt-4 gap-2">
|
| 214 |
-
<input
|
| 215 |
-
type="text"
|
| 216 |
-
id="user-question"
|
| 217 |
-
placeholder="Ask a question about your report"
|
| 218 |
-
class="flex-1 px-4 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2"
|
| 219 |
-
style="focus:ring-color: var(--tropical-indigo);"
|
| 220 |
-
/>
|
| 221 |
-
<button id="ask-btn" class="btn-primary px-4 py-2 rounded">
|
| 222 |
-
Ask
|
| 223 |
-
</button>
|
| 224 |
-
</div>
|
| 225 |
-
</div>
|
| 226 |
-
</main>
|
| 227 |
-
|
| 228 |
-
<!-- JS stays exactly the same as your original -->
|
| 229 |
-
<script type="module">
|
| 230 |
-
document.addEventListener("DOMContentLoaded", () => {
|
| 231 |
-
const recsOutput = document.getElementById("recommendations-output");
|
| 232 |
-
const loadingEl = document.getElementById("loading");
|
| 233 |
-
const summaryBox = document.getElementById("summaryBox");
|
| 234 |
-
const analyzeBtn = document.getElementById("analyze-btn");
|
| 235 |
-
const chatBox = document.getElementById("chat-output");
|
| 236 |
-
const userQuestionInput = document.getElementById("user-question");
|
| 237 |
-
const askBtn = document.getElementById("ask-btn");
|
| 238 |
-
|
| 239 |
-
let extractedText = "";
|
| 240 |
-
|
| 241 |
-
analyzeBtn.addEventListener("click", async () => {
|
| 242 |
-
const fileInput = document.getElementById("pdf-upload");
|
| 243 |
-
const file = fileInput.files[0];
|
| 244 |
-
|
| 245 |
-
if (!file) {
|
| 246 |
-
loadingEl.textContent = "Please upload a file first.";
|
| 247 |
-
return;
|
| 248 |
-
}
|
| 249 |
-
|
| 250 |
-
loadingEl.textContent = "Processing with AI...";
|
| 251 |
-
summaryBox.textContent = "...";
|
| 252 |
-
recsOutput.innerHTML = "";
|
| 253 |
-
|
| 254 |
-
try {
|
| 255 |
-
const formData = new FormData();
|
| 256 |
-
formData.append("file", file);
|
| 257 |
-
formData.append("model", "bert");
|
| 258 |
-
|
| 259 |
-
const response = await fetch(
|
| 260 |
-
"http://127.0.0.1:5501/analyzer.html",
|
| 261 |
-
{ method: "POST", body: formData }
|
| 262 |
-
);
|
| 263 |
-
|
| 264 |
-
if (!response.ok)
|
| 265 |
-
throw new Error(`Backend error: ${response.status}`);
|
| 266 |
-
|
| 267 |
-
const realData = await response.json();
|
| 268 |
-
extractedText = realData.ocr_text || "";
|
| 269 |
-
summaryBox.textContent = extractedText;
|
| 270 |
-
renderRecommendations(realData.resolutions);
|
| 271 |
-
loadingEl.textContent = "Analysis complete!";
|
| 272 |
-
} catch (error) {
|
| 273 |
-
console.error(error);
|
| 274 |
-
loadingEl.textContent = "Error: " + error.message;
|
| 275 |
-
}
|
| 276 |
-
});
|
| 277 |
-
|
| 278 |
-
function renderRecommendations(resolutions) {
|
| 279 |
-
if (!resolutions || resolutions.length === 0) {
|
| 280 |
-
recsOutput.textContent = "No recommendations found.";
|
| 281 |
-
return;
|
| 282 |
-
}
|
| 283 |
-
|
| 284 |
-
recsOutput.innerHTML = "";
|
| 285 |
-
|
| 286 |
-
resolutions.forEach((rec) => {
|
| 287 |
-
const severity = rec.severity.toLowerCase();
|
| 288 |
-
let badgeClass = "rec-badge";
|
| 289 |
-
|
| 290 |
-
if (severity.includes("high")) badgeClass += " badge-high";
|
| 291 |
-
else if (severity.includes("medium")) badgeClass += " badge-medium";
|
| 292 |
-
else if (severity.includes("low")) badgeClass += " badge-low";
|
| 293 |
-
|
| 294 |
-
const card = document.createElement("div");
|
| 295 |
-
card.className = "rec-card";
|
| 296 |
-
card.innerHTML = `
|
| 297 |
-
<div class="flex justify-between items-center mb-3">
|
| 298 |
-
<h4 class="rec-title">${rec.findings}</h4>
|
| 299 |
-
<span class="${badgeClass}">${rec.severity}</span>
|
| 300 |
-
</div>
|
| 301 |
-
<ul class="rec-content">
|
| 302 |
-
<li><strong>Recommendations:</strong> ${rec.recommendations.join(
|
| 303 |
-
", "
|
| 304 |
-
)}</li>
|
| 305 |
-
<li><strong>Treatment:</strong> ${
|
| 306 |
-
rec.treatment_suggestions
|
| 307 |
-
}</li>
|
| 308 |
-
<li><strong>Home Care:</strong> ${rec.home_care_guidance.join(
|
| 309 |
-
", "
|
| 310 |
-
)}</li>
|
| 311 |
-
<li><a href="${
|
| 312 |
-
rec.info_link
|
| 313 |
-
}" target="_blank" class="rec-link">Learn more</a></li>
|
| 314 |
-
</ul>
|
| 315 |
-
`;
|
| 316 |
-
recsOutput.appendChild(card);
|
| 317 |
-
});
|
| 318 |
-
}
|
| 319 |
-
|
| 320 |
-
askBtn.addEventListener("click", async () => {
|
| 321 |
-
const question = userQuestionInput.value.trim();
|
| 322 |
-
|
| 323 |
-
if (!question || !extractedText) {
|
| 324 |
-
alert("Please upload and analyze a report first!");
|
| 325 |
-
return;
|
| 326 |
-
}
|
| 327 |
-
|
| 328 |
-
chatBox.innerHTML += `<p><strong>You:</strong> ${question}</p>`;
|
| 329 |
-
chatBox.scrollTop = chatBox.scrollHeight;
|
| 330 |
-
|
| 331 |
-
const answerer = await pipeline(
|
| 332 |
-
"question-answering",
|
| 333 |
-
"Xenova/distilbert-base-uncased-distilled-squad"
|
| 334 |
-
);
|
| 335 |
-
const output = await answerer(question, extractedText);
|
| 336 |
-
|
| 337 |
-
chatBox.innerHTML += `<p><strong>Chatbot:</strong> ${output.answer}</p>`;
|
| 338 |
-
userQuestionInput.value = "";
|
| 339 |
-
chatBox.scrollTop = chatBox.scrollHeight;
|
| 340 |
-
});
|
| 341 |
-
});
|
| 342 |
-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