Spaces:
Sleeping

yaseen113 commited on
Commit
2bf2d2d
·
verified ·
1 Parent(s): d04eeeb

new change

Browse files
Files changed (1) hide show
  1. templates/index.html +896 -0
templates/index.html ADDED
@@ -0,0 +1,896 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>MicroScope — Microplastic Detection</title>
7
+ <link href="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Syne:wght@400;600;800&display=swap" rel="stylesheet" />
8
+ <style>
9
+ :root {
10
+ --bg: #050d0a;
11
+ --surface: #0b1912;
12
+ --border: #1a3328;
13
+ --accent: #00ffcc;
14
+ --accent2: #00c896;
15
+ --accent3: #ff4d6d;
16
+ --text: #e0fff7;
17
+ --muted: #5a8a78;
18
+ --glow: 0 0 24px rgba(0,255,204,0.18);
19
+ --font-display: 'Syne', sans-serif;
20
+ --font-mono: 'Space Mono', monospace;
21
+ }
22
+
23
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
24
+
25
+ body {
26
+ background: var(--bg);
27
+ color: var(--text);
28
+ font-family: var(--font-mono);
29
+ min-height: 100vh;
30
+ overflow-x: hidden;
31
+ }
32
+
33
+ /* Animated grid background */
34
+ body::before {
35
+ content: '';
36
+ position: fixed;
37
+ inset: 0;
38
+ background-image:
39
+ linear-gradient(rgba(0,255,204,0.03) 1px, transparent 1px),
40
+ linear-gradient(90deg, rgba(0,255,204,0.03) 1px, transparent 1px);
41
+ background-size: 48px 48px;
42
+ pointer-events: none;
43
+ z-index: 0;
44
+ }
45
+
46
+ /* Radial glow */
47
+ body::after {
48
+ content: '';
49
+ position: fixed;
50
+ top: -20%;
51
+ left: 50%;
52
+ transform: translateX(-50%);
53
+ width: 800px;
54
+ height: 500px;
55
+ background: radial-gradient(ellipse, rgba(0,255,204,0.06) 0%, transparent 70%);
56
+ pointer-events: none;
57
+ z-index: 0;
58
+ }
59
+
60
+ .container {
61
+ position: relative;
62
+ z-index: 1;
63
+ max-width: 1100px;
64
+ margin: 0 auto;
65
+ padding: 40px 24px 80px;
66
+ }
67
+
68
+ /* Header */
69
+ header {
70
+ display: flex;
71
+ align-items: center;
72
+ gap: 20px;
73
+ margin-bottom: 56px;
74
+ padding-bottom: 28px;
75
+ border-bottom: 1px solid var(--border);
76
+ }
77
+
78
+ .logo-icon {
79
+ width: 52px;
80
+ height: 52px;
81
+ border: 2px solid var(--accent);
82
+ border-radius: 14px;
83
+ display: flex;
84
+ align-items: center;
85
+ justify-content: center;
86
+ box-shadow: var(--glow);
87
+ flex-shrink: 0;
88
+ }
89
+
90
+ .logo-icon svg { width: 28px; height: 28px; }
91
+
92
+ .header-text h1 {
93
+ font-family: var(--font-display);
94
+ font-size: 28px;
95
+ font-weight: 800;
96
+ letter-spacing: -0.5px;
97
+ color: var(--text);
98
+ }
99
+
100
+ .header-text h1 span { color: var(--accent); }
101
+
102
+ .header-text p {
103
+ font-size: 11px;
104
+ color: var(--muted);
105
+ letter-spacing: 2px;
106
+ text-transform: uppercase;
107
+ margin-top: 4px;
108
+ }
109
+
110
+ .status-badge {
111
+ margin-left: auto;
112
+ display: flex;
113
+ align-items: center;
114
+ gap: 8px;
115
+ font-size: 11px;
116
+ color: var(--accent);
117
+ letter-spacing: 1px;
118
+ text-transform: uppercase;
119
+ }
120
+
121
+ .status-dot {
122
+ width: 8px; height: 8px;
123
+ border-radius: 50%;
124
+ background: var(--accent);
125
+ animation: pulse 2s ease-in-out infinite;
126
+ }
127
+
128
+ @keyframes pulse {
129
+ 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0,255,204,0.4); }
130
+ 50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(0,255,204,0); }
131
+ }
132
+
133
+ /* Main layout */
134
+ .main-grid {
135
+ display: grid;
136
+ grid-template-columns: 420px 1fr;
137
+ gap: 24px;
138
+ align-items: start;
139
+ }
140
+
141
+ @media (max-width: 800px) {
142
+ .main-grid { grid-template-columns: 1fr; }
143
+ }
144
+
145
+ /* Panel */
146
+ .panel {
147
+ background: var(--surface);
148
+ border: 1px solid var(--border);
149
+ border-radius: 16px;
150
+ overflow: hidden;
151
+ }
152
+
153
+ .panel-header {
154
+ padding: 16px 20px;
155
+ border-bottom: 1px solid var(--border);
156
+ font-size: 11px;
157
+ letter-spacing: 2px;
158
+ text-transform: uppercase;
159
+ color: var(--muted);
160
+ display: flex;
161
+ align-items: center;
162
+ gap: 8px;
163
+ }
164
+
165
+ .panel-header .dot {
166
+ width: 6px; height: 6px;
167
+ border-radius: 50%;
168
+ background: var(--accent);
169
+ }
170
+
171
+ /* Upload zone */
172
+ #drop-zone {
173
+ padding: 36px 24px;
174
+ display: flex;
175
+ flex-direction: column;
176
+ align-items: center;
177
+ justify-content: center;
178
+ gap: 16px;
179
+ cursor: pointer;
180
+ transition: all 0.3s ease;
181
+ min-height: 260px;
182
+ position: relative;
183
+ }
184
+
185
+ #drop-zone.dragover {
186
+ background: rgba(0,255,204,0.04);
187
+ border-color: var(--accent);
188
+ }
189
+
190
+ .upload-icon {
191
+ width: 64px; height: 64px;
192
+ border: 2px dashed var(--border);
193
+ border-radius: 50%;
194
+ display: flex;
195
+ align-items: center;
196
+ justify-content: center;
197
+ transition: all 0.3s;
198
+ }
199
+
200
+ #drop-zone:hover .upload-icon,
201
+ #drop-zone.dragover .upload-icon {
202
+ border-color: var(--accent);
203
+ box-shadow: var(--glow);
204
+ }
205
+
206
+ .upload-icon svg { width: 28px; height: 28px; opacity: 0.6; }
207
+
208
+ .upload-title {
209
+ font-family: var(--font-display);
210
+ font-size: 16px;
211
+ font-weight: 600;
212
+ color: var(--text);
213
+ text-align: center;
214
+ }
215
+
216
+ .upload-sub {
217
+ font-size: 11px;
218
+ color: var(--muted);
219
+ text-align: center;
220
+ line-height: 1.6;
221
+ }
222
+
223
+ #file-input { display: none; }
224
+
225
+ .btn {
226
+ display: inline-flex;
227
+ align-items: center;
228
+ gap: 8px;
229
+ padding: 10px 22px;
230
+ border-radius: 8px;
231
+ font-family: var(--font-mono);
232
+ font-size: 12px;
233
+ font-weight: 700;
234
+ letter-spacing: 1px;
235
+ text-transform: uppercase;
236
+ cursor: pointer;
237
+ transition: all 0.2s;
238
+ border: none;
239
+ }
240
+
241
+ .btn-primary {
242
+ background: var(--accent);
243
+ color: #000;
244
+ }
245
+
246
+ .btn-primary:hover {
247
+ background: #fff;
248
+ box-shadow: var(--glow);
249
+ }
250
+
251
+ .btn-outline {
252
+ background: transparent;
253
+ color: var(--accent);
254
+ border: 1px solid var(--accent);
255
+ }
256
+
257
+ .btn-outline:hover {
258
+ background: rgba(0,255,204,0.08);
259
+ }
260
+
261
+ .btn:disabled {
262
+ opacity: 0.4;
263
+ cursor: not-allowed;
264
+ }
265
+
266
+ /* Preview */
267
+ #preview-wrap {
268
+ display: none;
269
+ flex-direction: column;
270
+ gap: 0;
271
+ }
272
+
273
+ #preview-img {
274
+ width: 100%;
275
+ display: block;
276
+ max-height: 320px;
277
+ object-fit: contain;
278
+ background: #000;
279
+ }
280
+
281
+ .preview-actions {
282
+ padding: 14px 20px;
283
+ display: flex;
284
+ gap: 10px;
285
+ border-top: 1px solid var(--border);
286
+ background: var(--surface);
287
+ }
288
+
289
+ /* Results panel */
290
+ #results-panel {
291
+ display: flex;
292
+ flex-direction: column;
293
+ gap: 0;
294
+ }
295
+
296
+ /* Loading */
297
+ #loading {
298
+ display: none;
299
+ padding: 48px 24px;
300
+ flex-direction: column;
301
+ align-items: center;
302
+ gap: 20px;
303
+ }
304
+
305
+ .scanner-ring {
306
+ width: 80px; height: 80px;
307
+ border-radius: 50%;
308
+ border: 3px solid var(--border);
309
+ border-top-color: var(--accent);
310
+ animation: spin 0.8s linear infinite;
311
+ position: relative;
312
+ }
313
+
314
+ .scanner-ring::after {
315
+ content: '';
316
+ position: absolute;
317
+ inset: 8px;
318
+ border-radius: 50%;
319
+ border: 2px solid transparent;
320
+ border-top-color: rgba(0,255,204,0.4);
321
+ animation: spin 1.4s linear infinite reverse;
322
+ }
323
+
324
+ @keyframes spin { to { transform: rotate(360deg); } }
325
+
326
+ .loading-text {
327
+ font-size: 12px;
328
+ color: var(--accent);
329
+ letter-spacing: 2px;
330
+ text-transform: uppercase;
331
+ animation: blink 1.2s ease-in-out infinite;
332
+ }
333
+
334
+ @keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }
335
+
336
+ /* Results */
337
+ #result-content {
338
+ display: none;
339
+ }
340
+
341
+ .result-image-wrap {
342
+ position: relative;
343
+ background: #000;
344
+ }
345
+
346
+ #result-img {
347
+ width: 100%;
348
+ display: block;
349
+ max-height: 420px;
350
+ object-fit: contain;
351
+ }
352
+
353
+ .detection-count-badge {
354
+ position: absolute;
355
+ top: 14px;
356
+ right: 14px;
357
+ background: rgba(0,255,204,0.9);
358
+ color: #000;
359
+ font-family: var(--font-display);
360
+ font-weight: 800;
361
+ font-size: 14px;
362
+ padding: 6px 14px;
363
+ border-radius: 20px;
364
+ backdrop-filter: blur(8px);
365
+ }
366
+
367
+ .stats-row {
368
+ display: grid;
369
+ grid-template-columns: repeat(3, 1fr);
370
+ border-top: 1px solid var(--border);
371
+ }
372
+
373
+ .stat-item {
374
+ padding: 20px;
375
+ border-right: 1px solid var(--border);
376
+ text-align: center;
377
+ }
378
+
379
+ .stat-item:last-child { border-right: none; }
380
+
381
+ .stat-value {
382
+ font-family: var(--font-display);
383
+ font-size: 28px;
384
+ font-weight: 800;
385
+ color: var(--accent);
386
+ line-height: 1;
387
+ }
388
+
389
+ .stat-label {
390
+ font-size: 10px;
391
+ color: var(--muted);
392
+ letter-spacing: 1.5px;
393
+ text-transform: uppercase;
394
+ margin-top: 6px;
395
+ }
396
+
397
+ /* Detection list */
398
+ .detections-list {
399
+ border-top: 1px solid var(--border);
400
+ }
401
+
402
+ .detections-list-header {
403
+ padding: 14px 20px;
404
+ font-size: 11px;
405
+ letter-spacing: 2px;
406
+ text-transform: uppercase;
407
+ color: var(--muted);
408
+ border-bottom: 1px solid var(--border);
409
+ }
410
+
411
+ .detection-item {
412
+ display: flex;
413
+ align-items: center;
414
+ gap: 14px;
415
+ padding: 14px 20px;
416
+ border-bottom: 1px solid var(--border);
417
+ animation: slideIn 0.4s ease forwards;
418
+ opacity: 0;
419
+ transform: translateX(-12px);
420
+ }
421
+
422
+ @keyframes slideIn {
423
+ to { opacity: 1; transform: translateX(0); }
424
+ }
425
+
426
+ .det-index {
427
+ width: 28px; height: 28px;
428
+ border: 1px solid var(--border);
429
+ border-radius: 6px;
430
+ display: flex;
431
+ align-items: center;
432
+ justify-content: center;
433
+ font-size: 11px;
434
+ color: var(--muted);
435
+ flex-shrink: 0;
436
+ }
437
+
438
+ .det-info { flex: 1; }
439
+
440
+ .det-label {
441
+ font-family: var(--font-display);
442
+ font-size: 13px;
443
+ font-weight: 600;
444
+ color: var(--text);
445
+ }
446
+
447
+ .det-size {
448
+ font-size: 11px;
449
+ color: var(--muted);
450
+ margin-top: 2px;
451
+ }
452
+
453
+ .conf-bar-wrap {
454
+ width: 100px;
455
+ text-align: right;
456
+ }
457
+
458
+ .conf-value {
459
+ font-size: 13px;
460
+ font-weight: 700;
461
+ color: var(--accent);
462
+ margin-bottom: 4px;
463
+ }
464
+
465
+ .conf-bar {
466
+ height: 4px;
467
+ background: var(--border);
468
+ border-radius: 2px;
469
+ overflow: hidden;
470
+ }
471
+
472
+ .conf-fill {
473
+ height: 100%;
474
+ background: linear-gradient(90deg, var(--accent2), var(--accent));
475
+ border-radius: 2px;
476
+ transition: width 0.8s ease;
477
+ }
478
+
479
+ /* Empty / no detection state */
480
+ #no-result {
481
+ display: none;
482
+ padding: 48px 24px;
483
+ flex-direction: column;
484
+ align-items: center;
485
+ gap: 12px;
486
+ text-align: center;
487
+ }
488
+
489
+ .no-result-icon {
490
+ width: 56px; height: 56px;
491
+ border: 2px solid var(--border);
492
+ border-radius: 50%;
493
+ display: flex;
494
+ align-items: center;
495
+ justify-content: center;
496
+ color: var(--muted);
497
+ }
498
+
499
+ /* Placeholder state */
500
+ #placeholder {
501
+ padding: 64px 24px;
502
+ display: flex;
503
+ flex-direction: column;
504
+ align-items: center;
505
+ justify-content: center;
506
+ gap: 14px;
507
+ text-align: center;
508
+ color: var(--muted);
509
+ min-height: 300px;
510
+ }
511
+
512
+ .placeholder-title {
513
+ font-family: var(--font-display);
514
+ font-size: 18px;
515
+ font-weight: 600;
516
+ color: var(--border);
517
+ }
518
+
519
+ .watermark-grid {
520
+ display: grid;
521
+ grid-template-columns: repeat(5,1fr);
522
+ gap: 6px;
523
+ opacity: 0.25;
524
+ margin-bottom: 12px;
525
+ }
526
+
527
+ .wm-dot {
528
+ width: 10px; height: 10px;
529
+ border-radius: 50%;
530
+ background: var(--muted);
531
+ }
532
+
533
+ .wm-dot.lit {
534
+ background: var(--accent);
535
+ box-shadow: 0 0 6px var(--accent);
536
+ }
537
+
538
+ /* Risk banner */
539
+ .risk-banner {
540
+ margin: 16px 20px;
541
+ padding: 14px 18px;
542
+ border-radius: 10px;
543
+ border: 1px solid;
544
+ display: none;
545
+ align-items: flex-start;
546
+ gap: 12px;
547
+ }
548
+
549
+ .risk-banner.high {
550
+ border-color: var(--accent3);
551
+ background: rgba(255,77,109,0.06);
552
+ }
553
+
554
+ .risk-banner.low {
555
+ border-color: var(--accent2);
556
+ background: rgba(0,200,150,0.06);
557
+ }
558
+
559
+ .risk-banner.none {
560
+ border-color: var(--border);
561
+ background: rgba(90,138,120,0.06);
562
+ }
563
+
564
+ .risk-icon { font-size: 20px; }
565
+
566
+ .risk-text strong {
567
+ display: block;
568
+ font-family: var(--font-display);
569
+ font-size: 13px;
570
+ font-weight: 600;
571
+ margin-bottom: 4px;
572
+ }
573
+
574
+ .risk-text p {
575
+ font-size: 11px;
576
+ color: var(--muted);
577
+ line-height: 1.5;
578
+ }
579
+ </style>
580
+ </head>
581
+ <body>
582
+ <div class="container">
583
+
584
+ <!-- Header -->
585
+ <header>
586
+ <div class="logo-icon">
587
+ <svg viewBox="0 0 24 24" fill="none" stroke="#00ffcc" stroke-width="1.8">
588
+ <circle cx="11" cy="11" r="7"/>
589
+ <line x1="16.5" y1="16.5" x2="22" y2="22"/>
590
+ <circle cx="11" cy="11" r="3" stroke-dasharray="2 2"/>
591
+ <line x1="11" y1="4" x2="11" y2="6"/>
592
+ <line x1="11" y1="16" x2="11" y2="18"/>
593
+ <line x1="4" y1="11" x2="6" y2="11"/>
594
+ <line x1="16" y1="11" x2="18" y2="11"/>
595
+ </svg>
596
+ </div>
597
+ <div class="header-text">
598
+ <h1>Micro<span>Scope</span></h1>
599
+ <p>AI-Powered Microplastic Detection</p>
600
+ </div>
601
+ <div class="status-badge">
602
+ <div class="status-dot"></div>
603
+ Model Online
604
+ </div>
605
+ </header>
606
+
607
+ <!-- Grid -->
608
+ <div class="main-grid">
609
+
610
+ <!-- Left: Upload Panel -->
611
+ <div class="panel">
612
+ <div class="panel-header">
613
+ <div class="dot"></div>
614
+ Input Image
615
+ </div>
616
+
617
+ <!-- Drop zone -->
618
+ <div id="drop-zone" onclick="document.getElementById('file-input').click()">
619
+ <div class="upload-icon">
620
+ <svg viewBox="0 0 24 24" fill="none" stroke="#00ffcc" stroke-width="1.6">
621
+ <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/>
622
+ <polyline points="17 8 12 3 7 8"/>
623
+ <line x1="12" y1="3" x2="12" y2="15"/>
624
+ </svg>
625
+ </div>
626
+ <div class="upload-title">Drop your image here</div>
627
+ <div class="upload-sub">JPG, PNG, BMP, TIFF supported<br/>Works best with microscopy images</div>
628
+ <button class="btn btn-outline" onclick="event.stopPropagation(); document.getElementById('file-input').click()">Browse Files</button>
629
+ <input type="file" id="file-input" accept="image/*" />
630
+ </div>
631
+
632
+ <!-- Preview -->
633
+ <div id="preview-wrap">
634
+ <img id="preview-img" alt="Preview" />
635
+ <div class="preview-actions">
636
+ <button class="btn btn-primary" id="analyze-btn" onclick="analyzeImage()">
637
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
638
+ <path d="M5 3l14 9-14 9V3z"/>
639
+ </svg>
640
+ Analyze
641
+ </button>
642
+ <button class="btn btn-outline" onclick="resetAll()">Reset</button>
643
+ </div>
644
+ </div>
645
+ </div>
646
+
647
+ <!-- Right: Results Panel -->
648
+ <div class="panel" id="results-panel">
649
+
650
+ <!-- Placeholder -->
651
+ <div id="placeholder">
652
+ <div class="watermark-grid" id="wm-grid"></div>
653
+ <div class="placeholder-title">Awaiting Sample</div>
654
+ <p style="font-size:12px; color:var(--muted); max-width:240px; line-height:1.6;">
655
+ Upload a microscopy or water sample image to detect microplastic particles.
656
+ </p>
657
+ </div>
658
+
659
+ <!-- Loading -->
660
+ <div id="loading">
661
+ <div class="scanner-ring"></div>
662
+ <div class="loading-text">Scanning for microplastics…</div>
663
+ </div>
664
+
665
+ <!-- Result -->
666
+ <div id="result-content">
667
+ <div class="result-image-wrap">
668
+ <img id="result-img" alt="Detection Result" />
669
+ <div class="detection-count-badge" id="count-badge"></div>
670
+ </div>
671
+
672
+ <!-- Risk banner -->
673
+ <div class="risk-banner" id="risk-banner">
674
+ <div class="risk-icon" id="risk-icon"></div>
675
+ <div class="risk-text">
676
+ <strong id="risk-title"></strong>
677
+ <p id="risk-desc"></p>
678
+ </div>
679
+ </div>
680
+
681
+ <!-- Stats -->
682
+ <div class="stats-row">
683
+ <div class="stat-item">
684
+ <div class="stat-value" id="stat-count">0</div>
685
+ <div class="stat-label">Particles Found</div>
686
+ </div>
687
+ <div class="stat-item">
688
+ <div class="stat-value" id="stat-conf">—</div>
689
+ <div class="stat-label">Avg Confidence</div>
690
+ </div>
691
+ <div class="stat-item">
692
+ <div class="stat-value" id="stat-risk">—</div>
693
+ <div class="stat-label">Risk Level</div>
694
+ </div>
695
+ </div>
696
+
697
+ <!-- Detections list -->
698
+ <div class="detections-list" id="detections-list"></div>
699
+
700
+ <!-- No detections -->
701
+ <div id="no-result">
702
+ <div class="no-result-icon">
703
+ <svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
704
+ <path d="M22 11.08V12a10 10 0 11-5.93-9.14"/>
705
+ <polyline points="22 4 12 14.01 9 11.01"/>
706
+ </svg>
707
+ </div>
708
+ <div style="font-family:var(--font-display); font-size:15px; font-weight:600; color:var(--text)">No Microplastics Detected</div>
709
+ <p style="font-size:12px; color:var(--muted);">The sample appears clean or particles are below the confidence threshold.</p>
710
+ </div>
711
+ </div>
712
+
713
+ </div>
714
+ </div>
715
+ </div>
716
+
717
+ <script>
718
+ const fileInput = document.getElementById('file-input');
719
+ const dropZone = document.getElementById('drop-zone');
720
+ const previewWrap = document.getElementById('preview-wrap');
721
+ const previewImg = document.getElementById('preview-img');
722
+ const analyzeBtn = document.getElementById('analyze-btn');
723
+ let selectedFile = null;
724
+
725
+ // Watermark dots
726
+ const wm = document.getElementById('wm-grid');
727
+ for (let i = 0; i < 25; i++) {
728
+ const d = document.createElement('div');
729
+ d.className = 'wm-dot' + (Math.random() > 0.7 ? ' lit' : '');
730
+ wm.appendChild(d);
731
+ }
732
+
733
+ // Drag & drop
734
+ dropZone.addEventListener('dragover', e => { e.preventDefault(); dropZone.classList.add('dragover'); });
735
+ dropZone.addEventListener('dragleave', () => dropZone.classList.remove('dragover'));
736
+ dropZone.addEventListener('drop', e => {
737
+ e.preventDefault();
738
+ dropZone.classList.remove('dragover');
739
+ const f = e.dataTransfer.files[0];
740
+ if (f && f.type.startsWith('image/')) loadFile(f);
741
+ });
742
+
743
+ fileInput.addEventListener('change', () => {
744
+ if (fileInput.files[0]) loadFile(fileInput.files[0]);
745
+ });
746
+
747
+ function loadFile(file) {
748
+ selectedFile = file;
749
+ const reader = new FileReader();
750
+ reader.onload = e => {
751
+ previewImg.src = e.target.result;
752
+ dropZone.style.display = 'none';
753
+ previewWrap.style.display = 'flex';
754
+ previewWrap.style.flexDirection = 'column';
755
+ showPlaceholder();
756
+ };
757
+ reader.readAsDataURL(file);
758
+ }
759
+
760
+ function showPlaceholder() {
761
+ document.getElementById('placeholder').style.display = 'flex';
762
+ document.getElementById('placeholder').style.flexDirection = 'column';
763
+ document.getElementById('loading').style.display = 'none';
764
+ document.getElementById('result-content').style.display = 'none';
765
+ document.getElementById('no-result').style.display = 'none';
766
+ }
767
+
768
+ function showLoading() {
769
+ document.getElementById('placeholder').style.display = 'none';
770
+ document.getElementById('loading').style.display = 'flex';
771
+ document.getElementById('loading').style.flexDirection = 'column';
772
+ document.getElementById('result-content').style.display = 'none';
773
+ document.getElementById('no-result').style.display = 'none';
774
+ }
775
+
776
+ function resetAll() {
777
+ selectedFile = null;
778
+ fileInput.value = '';
779
+ previewImg.src = '';
780
+ dropZone.style.display = 'flex';
781
+ previewWrap.style.display = 'none';
782
+ showPlaceholder();
783
+ }
784
+
785
+ async function analyzeImage() {
786
+ if (!selectedFile) return;
787
+ analyzeBtn.disabled = true;
788
+ showLoading();
789
+
790
+ const formData = new FormData();
791
+ formData.append('image', selectedFile);
792
+
793
+ try {
794
+ const res = await fetch('/detect', { method: 'POST', body: formData });
795
+ const data = await res.json();
796
+
797
+ if (data.error) throw new Error(data.error);
798
+ showResults(data);
799
+ } catch (err) {
800
+ alert('Detection failed: ' + err.message);
801
+ showPlaceholder();
802
+ } finally {
803
+ analyzeBtn.disabled = false;
804
+ }
805
+ }
806
+
807
+ function showResults(data) {
808
+ document.getElementById('loading').style.display = 'none';
809
+ document.getElementById('placeholder').style.display = 'none';
810
+ document.getElementById('no-result').style.display = 'none';
811
+
812
+ const rc = document.getElementById('result-content');
813
+ rc.style.display = 'block';
814
+
815
+ const total = data.total_detections;
816
+ const avgConf = data.average_confidence;
817
+ const detections = data.detections;
818
+
819
+ // Image
820
+ document.getElementById('result-img').src = data.annotated_image;
821
+ document.getElementById('count-badge').textContent = `${total} particle${total !== 1 ? 's' : ''} found`;
822
+
823
+ // Risk level
824
+ let riskLabel, riskColor;
825
+ if (total === 0) { riskLabel = 'CLEAN'; riskColor = '#00c896'; }
826
+ else if (total <= 3) { riskLabel = 'LOW'; riskColor = '#00c896'; }
827
+ else if (total <= 8) { riskLabel = 'MED'; riskColor = '#f0a500'; }
828
+ else { riskLabel = 'HIGH'; riskColor = '#ff4d6d'; }
829
+
830
+ // Stats
831
+ document.getElementById('stat-count').textContent = total;
832
+ document.getElementById('stat-conf').textContent = total > 0 ? (avgConf * 100).toFixed(1) + '%' : '—';
833
+ document.getElementById('stat-risk').textContent = riskLabel;
834
+ document.getElementById('stat-risk').style.color = riskColor;
835
+
836
+ // Risk banner
837
+ const banner = document.getElementById('risk-banner');
838
+ banner.className = 'risk-banner';
839
+ if (total === 0) {
840
+ banner.classList.add('none');
841
+ document.getElementById('risk-icon').textContent = '✅';
842
+ document.getElementById('risk-title').textContent = 'No Microplastics Detected';
843
+ document.getElementById('risk-desc').textContent = 'This sample appears free of microplastic contamination at the current confidence threshold.';
844
+ } else if (total <= 3) {
845
+ banner.classList.add('low');
846
+ document.getElementById('risk-icon').textContent = '🟡';
847
+ document.getElementById('risk-title').textContent = 'Low Microplastic Presence';
848
+ document.getElementById('risk-desc').textContent = `${total} particle(s) detected. Contamination level is low but monitoring is recommended.`;
849
+ } else if (total <= 8) {
850
+ banner.classList.add('high');
851
+ document.getElementById('risk-icon').textContent = '🟠';
852
+ document.getElementById('risk-title').textContent = 'Moderate Contamination';
853
+ document.getElementById('risk-desc').textContent = `${total} microplastic particles found. Consider filtration or further analysis.`;
854
+ } else {
855
+ banner.classList.add('high');
856
+ document.getElementById('risk-icon').textContent = '🔴';
857
+ document.getElementById('risk-title').textContent = 'High Contamination Alert';
858
+ document.getElementById('risk-desc').textContent = `${total} microplastic particles detected! This sample has significant contamination requiring immediate attention.`;
859
+ }
860
+ banner.style.display = 'flex';
861
+
862
+ // Detection list
863
+ const list = document.getElementById('detections-list');
864
+ list.innerHTML = '';
865
+
866
+ if (detections.length > 0) {
867
+ const hdr = document.createElement('div');
868
+ hdr.className = 'detections-list-header';
869
+ hdr.textContent = `Detected Particles (${detections.length})`;
870
+ list.appendChild(hdr);
871
+
872
+ detections.forEach((d, i) => {
873
+ const item = document.createElement('div');
874
+ item.className = 'detection-item';
875
+ item.style.animationDelay = `${i * 60}ms`;
876
+ item.innerHTML = `
877
+ <div class="det-index">${i + 1}</div>
878
+ <div class="det-info">
879
+ <div class="det-label">${d.label}</div>
880
+ <div class="det-size">${d.width_px} × ${d.height_px} px &nbsp;|&nbsp; bbox [${d.bbox.join(', ')}]</div>
881
+ </div>
882
+ <div class="conf-bar-wrap">
883
+ <div class="conf-value">${(d.confidence * 100).toFixed(1)}%</div>
884
+ <div class="conf-bar"><div class="conf-fill" style="width:${d.confidence * 100}%"></div></div>
885
+ </div>
886
+ `;
887
+ list.appendChild(item);
888
+ });
889
+ } else {
890
+ document.getElementById('no-result').style.display = 'flex';
891
+ document.getElementById('no-result').style.flexDirection = 'column';
892
+ }
893
+ }
894
+ </script>
895
+ </body>
896
+ </html>