Spaces:
Running
Running
Commit ·
4a9bab2
1
Parent(s): efb8317
RetinaPlus
Browse files- .dockerignore +12 -0
- .gitattributes +1 -0
- Dockerfile +25 -0
- README.md +37 -4
- app.py +222 -0
- dashboard.css +37 -0
- dashboard.html +56 -0
- dashboard.js +28 -0
- detect.css +210 -0
- detect.html +144 -0
- detect.js +129 -0
- homepage.css +101 -0
- homepage.html +158 -0
- homepage.js +10 -0
- icon.png +3 -0
- models/README.txt +1 -0
- models/v3_best.pt +3 -0
- models/v4_best.pt +3 -0
- requirements.txt +8 -0
- shared.css +134 -0
- shared.js +45 -0
.dockerignore
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# dev / non-runtime files — keep the Cloud Run image lean
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.pyc
|
| 4 |
+
.git/
|
| 5 |
+
.gitignore
|
| 6 |
+
.claude/
|
| 7 |
+
_makeicon.py
|
| 8 |
+
test.html
|
| 9 |
+
logo.png
|
| 10 |
+
history.json
|
| 11 |
+
*.md
|
| 12 |
+
models/README.txt
|
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ 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 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ── RetinaPlus · Cloud Run ──
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
+
|
| 4 |
+
# lib ที่ opencv ต้องใช้
|
| 5 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
+
libgl1 libglib2.0-0 \
|
| 7 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
+
|
| 9 |
+
WORKDIR /app
|
| 10 |
+
|
| 11 |
+
COPY requirements.txt .
|
| 12 |
+
# torch CPU build (เล็กกว่า + Cloud Run ไม่มี GPU)
|
| 13 |
+
RUN pip install --no-cache-dir torch==2.2.2 --index-url https://download.pytorch.org/whl/cpu \
|
| 14 |
+
&& pip install --no-cache-dir -r requirements.txt
|
| 15 |
+
|
| 16 |
+
COPY . .
|
| 17 |
+
|
| 18 |
+
# Cloud Run ส่ง PORT=8080
|
| 19 |
+
ENV PORT=8080
|
| 20 |
+
# history เขียนที่ /tmp (เขียนได้เสมอ ทั้ง HF Spaces / Cloud Run)
|
| 21 |
+
ENV HISTORY_FILE=/tmp/retinaplus_history.json
|
| 22 |
+
|
| 23 |
+
# 1 worker / หลาย thread → โมเดลโหลดครั้งเดียวแชร์ใน RAM
|
| 24 |
+
# timeout 0 = ไม่ตัด request ระหว่างประมวลผลภาพ/Grad-CAM
|
| 25 |
+
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 app:app
|
README.md
CHANGED
|
@@ -1,10 +1,43 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: RetinaPlus
|
| 3 |
+
emoji: 👁️
|
| 4 |
+
colorFrom: blue
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 8080
|
| 8 |
pinned: false
|
| 9 |
+
short_description: AI diabetic retinopathy screening
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# RetinaPlus — AI Diabetic Retinopathy Screening
|
| 13 |
+
|
| 14 |
+
เครื่องมือคัดกรองเบาหวานขึ้นจอตาด้วย AI · Flask + PyTorch (EfficientNet-B4 ordinal regression, ensemble v3+v4 + TTA) + Grad-CAM
|
| 15 |
+
|
| 16 |
+
> ⚠️ เครื่องมือคัดกรองเบื้องต้น ไม่ใช่การวินิจฉัย ผลควรได้รับการยืนยันโดยจักษุแพทย์
|
| 17 |
+
|
| 18 |
+
## หน้าเว็บ
|
| 19 |
+
- `/` หน้าแรก · `/detect` ถ่าย/อัปโหลดภาพจอตา → ผลตรวจ · `/dashboard` สรุปผล
|
| 20 |
+
|
| 21 |
+
## โมเดล
|
| 22 |
+
EfficientNet-B4 ensemble (2 seeds) — `models/v3_best.pt`, `models/v4_best.pt`
|
| 23 |
+
ถ้าโฟลเดอร์ว่าง → รันได้แต่เป็น "โหมดสาธิต"
|
| 24 |
+
|
| 25 |
+
## รัน Local
|
| 26 |
+
```bash
|
| 27 |
+
pip install torch --index-url https://download.pytorch.org/whl/cpu
|
| 28 |
+
pip install -r requirements.txt
|
| 29 |
+
python app.py # http://localhost:8080
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
## Deploy
|
| 33 |
+
- **Hugging Face Spaces (Docker):** push repo นี้ → HF build จาก Dockerfile อัตโนมัติ (`app_port: 8080`)
|
| 34 |
+
- **Google Cloud Run:** `gcloud run deploy retinaplus --source . --memory 2Gi --cpu 2 --allow-unauthenticated`
|
| 35 |
+
|
| 36 |
+
## API
|
| 37 |
+
| route | |
|
| 38 |
+
|---|---|
|
| 39 |
+
| `GET /status` | สถานะโมเดล |
|
| 40 |
+
| `POST /predict` | form-data `image` → JSON: grade, score, referable, risk_percent, gradcam(base64) |
|
| 41 |
+
| `GET /history` · `GET /stats` | ประวัติ + สรุป |
|
| 42 |
+
|
| 43 |
+
Developed by Nathakorn
|
app.py
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
RetinaPlus — AI Diabetic Retinopathy Screening (web)
|
| 3 |
+
Flask + PyTorch (EfficientNet-B4 ordinal regression) + Grad-CAM
|
| 4 |
+
โครงเดียวกับ Cough AI: เสิร์ฟ static html + /predict API + Cloud Run ready
|
| 5 |
+
"""
|
| 6 |
+
import os, io, json, base64, datetime, traceback
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
import numpy as np
|
| 10 |
+
import cv2
|
| 11 |
+
from flask import Flask, request, jsonify, send_from_directory
|
| 12 |
+
from flask_cors import CORS
|
| 13 |
+
|
| 14 |
+
import torch
|
| 15 |
+
import torch.nn as nn
|
| 16 |
+
import timm
|
| 17 |
+
|
| 18 |
+
# ------------------------------------------------------------------ config
|
| 19 |
+
HERE = Path(__file__).resolve().parent
|
| 20 |
+
MODELS_DIR = HERE / "models"
|
| 21 |
+
HISTORY_FILE = Path(os.environ.get("HISTORY_FILE") or (HERE / "history.json"))
|
| 22 |
+
IMG_SIZE = 380
|
| 23 |
+
BACKBONE = "efficientnet_b4"
|
| 24 |
+
CLASS_NAMES = ["No DR", "Mild", "Moderate", "Severe", "Proliferative"]
|
| 25 |
+
# OptimizedRounder coefs จาก v4 (เส้นแบ่งเกรด) + referable = coef[1]
|
| 26 |
+
ROUNDER_COEFS = [0.515, 1.264, 2.376, 3.079]
|
| 27 |
+
REFERABLE_THR = ROUNDER_COEFS[1]
|
| 28 |
+
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
| 29 |
+
|
| 30 |
+
# ------------------------------------------------------------------ model
|
| 31 |
+
def build_model():
|
| 32 |
+
m = timm.create_model(BACKBONE, pretrained=False, num_classes=1,
|
| 33 |
+
drop_rate=0.3, drop_path_rate=0.2)
|
| 34 |
+
return m.to(DEVICE).eval()
|
| 35 |
+
|
| 36 |
+
MEMBERS = []
|
| 37 |
+
def load_models():
|
| 38 |
+
"""โหลด best*.pt ทุกตัวใน models/ มาเป็น ensemble (ถ้าไม่มี = โหมด demo)"""
|
| 39 |
+
global MEMBERS
|
| 40 |
+
MEMBERS = []
|
| 41 |
+
if MODELS_DIR.exists():
|
| 42 |
+
for p in sorted(MODELS_DIR.glob("*.pt")):
|
| 43 |
+
try:
|
| 44 |
+
m = build_model()
|
| 45 |
+
m.load_state_dict(torch.load(str(p), map_location=DEVICE))
|
| 46 |
+
MEMBERS.append(m)
|
| 47 |
+
print(f"[model] loaded {p.name}")
|
| 48 |
+
except Exception as e:
|
| 49 |
+
print(f"[model] skip {p.name}: {e}")
|
| 50 |
+
print(f"[model] {len(MEMBERS)} model(s) | device={DEVICE}")
|
| 51 |
+
load_models()
|
| 52 |
+
|
| 53 |
+
# ------------------------------------------------------------------ preprocessing
|
| 54 |
+
_MEAN = np.array([0.485, 0.456, 0.406]); _STD = np.array([0.229, 0.224, 0.225])
|
| 55 |
+
|
| 56 |
+
def _crop_fundus(img, tol=7):
|
| 57 |
+
g = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY); mask = g > tol
|
| 58 |
+
if mask.sum() == 0: return img
|
| 59 |
+
c = np.argwhere(mask); y0, x0 = c.min(0); y1, x1 = c.max(0) + 1
|
| 60 |
+
return img[y0:y1, x0:x1]
|
| 61 |
+
|
| 62 |
+
def _clahe(img):
|
| 63 |
+
lab = cv2.cvtColor(img, cv2.COLOR_BGR2LAB); l, a, b = cv2.split(lab)
|
| 64 |
+
l = cv2.createCLAHE(2.0, (8, 8)).apply(l)
|
| 65 |
+
return cv2.cvtColor(cv2.merge((l, a, b)), cv2.COLOR_LAB2BGR)
|
| 66 |
+
|
| 67 |
+
def preprocess(bgr):
|
| 68 |
+
img = _crop_fundus(bgr)
|
| 69 |
+
if img.size == 0: img = bgr
|
| 70 |
+
img = cv2.resize(img, (IMG_SIZE, IMG_SIZE), interpolation=cv2.INTER_AREA)
|
| 71 |
+
img = _clahe(img)
|
| 72 |
+
return cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # RGB uint8
|
| 73 |
+
|
| 74 |
+
def to_tensor(rgb):
|
| 75 |
+
x = ((rgb / 255.0 - _MEAN) / _STD).transpose(2, 0, 1).astype(np.float32)
|
| 76 |
+
return torch.from_numpy(x).unsqueeze(0).to(DEVICE)
|
| 77 |
+
|
| 78 |
+
def grade_from_score(s):
|
| 79 |
+
return int(np.clip(np.digitize([s], ROUNDER_COEFS)[0], 0, 4))
|
| 80 |
+
|
| 81 |
+
def is_fundus(bgr):
|
| 82 |
+
"""heuristic: ภาพจอตา = โทนแดง/ส้ม + มีบริเวณสว่างเป็นก้อนใหญ่"""
|
| 83 |
+
img = cv2.resize(bgr, (256, 256))
|
| 84 |
+
rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB).astype(float)
|
| 85 |
+
redness = float(rgb[:, :, 0].mean() - rgb[:, :, 2].mean()) # R - B
|
| 86 |
+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
| 87 |
+
_, th = cv2.threshold(gray, 18, 255, cv2.THRESH_BINARY)
|
| 88 |
+
cnts, _ = cv2.findContours(th, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
| 89 |
+
fill = (max(cv2.contourArea(c) for c in cnts) / (256 * 256)) if cnts else 0.0
|
| 90 |
+
return (redness > 18) and (fill > 0.15)
|
| 91 |
+
|
| 92 |
+
# ------------------------------------------------------------------ inference + grad-cam
|
| 93 |
+
@torch.no_grad()
|
| 94 |
+
def ensemble_score(x):
|
| 95 |
+
ss = []
|
| 96 |
+
for m in MEMBERS:
|
| 97 |
+
o = m(x).float().squeeze(1)
|
| 98 |
+
o = o + m(torch.flip(x, [3])).float().squeeze(1) + m(torch.flip(x, [2])).float().squeeze(1)
|
| 99 |
+
ss.append(float((o / 3).item()))
|
| 100 |
+
return float(np.mean(ss))
|
| 101 |
+
|
| 102 |
+
def gradcam_overlay(rgb, x):
|
| 103 |
+
"""heatmap จากโมเดลตัวแรก + mask วงจอตา -> base64 png"""
|
| 104 |
+
try:
|
| 105 |
+
from pytorch_grad_cam import GradCAMPlusPlus
|
| 106 |
+
from pytorch_grad_cam.utils.image import show_cam_on_image
|
| 107 |
+
m0 = MEMBERS[0]
|
| 108 |
+
tl = m0.blocks[-2] if (hasattr(m0, "blocks") and len(m0.blocks) >= 2) else m0.conv_head
|
| 109 |
+
cam = GradCAMPlusPlus(model=m0, target_layers=[tl])
|
| 110 |
+
class T:
|
| 111 |
+
def __call__(self, o): return o[0]
|
| 112 |
+
gray = cam(input_tensor=x, targets=[T()])[0]
|
| 113 |
+
g = cv2.cvtColor(rgb, cv2.COLOR_RGB2GRAY)
|
| 114 |
+
mask = cv2.erode((g > 15).astype(np.float32), np.ones((25, 25), np.uint8))
|
| 115 |
+
gray = gray * mask
|
| 116 |
+
if gray.max() > 1e-6: gray = gray / gray.max()
|
| 117 |
+
ov = show_cam_on_image(rgb.astype(np.float32) / 255.0, gray, use_rgb=True)
|
| 118 |
+
ok, buf = cv2.imencode(".png", cv2.cvtColor(ov, cv2.COLOR_RGB2BGR))
|
| 119 |
+
return base64.b64encode(buf).decode() if ok else None
|
| 120 |
+
except Exception as e:
|
| 121 |
+
print("[gradcam] skip:", e); return None
|
| 122 |
+
|
| 123 |
+
def b64_png(rgb):
|
| 124 |
+
ok, buf = cv2.imencode(".png", cv2.cvtColor(rgb, cv2.COLOR_RGB2BGR))
|
| 125 |
+
return base64.b64encode(buf).decode() if ok else None
|
| 126 |
+
|
| 127 |
+
# ------------------------------------------------------------------ history
|
| 128 |
+
def save_history(rec):
|
| 129 |
+
try:
|
| 130 |
+
data = load_history()
|
| 131 |
+
data.insert(0, rec); data = data[:200]
|
| 132 |
+
HISTORY_FILE.write_text(json.dumps(data, ensure_ascii=False), encoding="utf-8")
|
| 133 |
+
except Exception:
|
| 134 |
+
pass # read-only filesystem (e.g. HF Spaces) — skip persistence silently
|
| 135 |
+
|
| 136 |
+
def load_history(limit=200):
|
| 137 |
+
if HISTORY_FILE.exists():
|
| 138 |
+
try: return json.loads(HISTORY_FILE.read_text(encoding="utf-8"))[:limit]
|
| 139 |
+
except Exception: return []
|
| 140 |
+
return []
|
| 141 |
+
|
| 142 |
+
# ------------------------------------------------------------------ flask
|
| 143 |
+
app = Flask(__name__, static_folder=".", static_url_path="")
|
| 144 |
+
CORS(app)
|
| 145 |
+
|
| 146 |
+
@app.route("/")
|
| 147 |
+
def home(): return send_from_directory(".", "homepage.html")
|
| 148 |
+
@app.route("/detect")
|
| 149 |
+
def detect(): return send_from_directory(".", "detect.html")
|
| 150 |
+
@app.route("/dashboard")
|
| 151 |
+
def dash(): return send_from_directory(".", "dashboard.html")
|
| 152 |
+
|
| 153 |
+
@app.route("/<path:f>")
|
| 154 |
+
def assets(f):
|
| 155 |
+
if (HERE / f).is_file(): return send_from_directory(".", f)
|
| 156 |
+
return ("", 404)
|
| 157 |
+
|
| 158 |
+
@app.route("/status")
|
| 159 |
+
def status():
|
| 160 |
+
return jsonify({"ok": True, "models": len(MEMBERS), "device": DEVICE,
|
| 161 |
+
"demo": len(MEMBERS) == 0})
|
| 162 |
+
|
| 163 |
+
@app.route("/predict", methods=["POST"])
|
| 164 |
+
def predict():
|
| 165 |
+
try:
|
| 166 |
+
if "image" not in request.files:
|
| 167 |
+
return jsonify({"error": "no image"}), 400
|
| 168 |
+
raw = np.frombuffer(request.files["image"].read(), np.uint8)
|
| 169 |
+
bgr = cv2.imdecode(raw, cv2.IMREAD_COLOR)
|
| 170 |
+
if bgr is None: return jsonify({"error": "bad image"}), 400
|
| 171 |
+
|
| 172 |
+
if not is_fundus(bgr):
|
| 173 |
+
return jsonify({"not_fundus": True,
|
| 174 |
+
"message_th": "ภาพนี้ไม่ใช่ภาพจอประสาทตา — กรุณาถ่าย/อัปโหลดภาพถ่ายจอตา (fundus)",
|
| 175 |
+
"message_en": "This is not a retinal fundus image — please capture/upload a fundus photo."})
|
| 176 |
+
|
| 177 |
+
rgb = preprocess(bgr)
|
| 178 |
+
|
| 179 |
+
if len(MEMBERS) == 0: # demo mode (ไม่มีโมเดล)
|
| 180 |
+
score = 1.9
|
| 181 |
+
res = {"demo": True}
|
| 182 |
+
else:
|
| 183 |
+
x = to_tensor(rgb)
|
| 184 |
+
score = ensemble_score(x)
|
| 185 |
+
res = {"demo": False}
|
| 186 |
+
|
| 187 |
+
grade = grade_from_score(score)
|
| 188 |
+
referable = score >= REFERABLE_THR
|
| 189 |
+
# map score 0-4 -> referable risk % (sigmoid รอบ threshold)
|
| 190 |
+
risk = float(1 / (1 + np.exp(-(score - REFERABLE_THR) * 2.2)) * 100)
|
| 191 |
+
cam = gradcam_overlay(rgb, x) if len(MEMBERS) else None
|
| 192 |
+
|
| 193 |
+
res.update({
|
| 194 |
+
"grade": grade, "grade_name": CLASS_NAMES[grade],
|
| 195 |
+
"score": round(score, 2),
|
| 196 |
+
"referable": bool(referable),
|
| 197 |
+
"risk_percent": round(risk, 1),
|
| 198 |
+
"preprocessed": b64_png(rgb),
|
| 199 |
+
"gradcam": cam,
|
| 200 |
+
})
|
| 201 |
+
save_history({"time": datetime.datetime.now().isoformat(timespec="seconds"),
|
| 202 |
+
"grade": grade, "grade_name": CLASS_NAMES[grade],
|
| 203 |
+
"referable": bool(referable), "risk_percent": round(risk, 1)})
|
| 204 |
+
return jsonify(res)
|
| 205 |
+
except Exception as e:
|
| 206 |
+
traceback.print_exc()
|
| 207 |
+
return jsonify({"error": str(e)}), 500
|
| 208 |
+
|
| 209 |
+
@app.route("/history")
|
| 210 |
+
def history(): return jsonify(load_history())
|
| 211 |
+
|
| 212 |
+
@app.route("/stats")
|
| 213 |
+
def stats():
|
| 214 |
+
h = load_history()
|
| 215 |
+
n = len(h); ref = sum(1 for x in h if x.get("referable"))
|
| 216 |
+
dist = {c: 0 for c in CLASS_NAMES}
|
| 217 |
+
for x in h: dist[x.get("grade_name", "No DR")] = dist.get(x.get("grade_name", "No DR"), 0) + 1
|
| 218 |
+
return jsonify({"total": n, "referable": ref, "normal": n - ref, "dist": dist})
|
| 219 |
+
|
| 220 |
+
if __name__ == "__main__":
|
| 221 |
+
port = int(os.environ.get("PORT", 8080))
|
| 222 |
+
app.run(host="0.0.0.0", port=port, debug=True)
|
dashboard.css
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* RetinaPlus — dashboard */
|
| 2 |
+
.dash{padding:40px 24px 60px}
|
| 3 |
+
.dash-head{margin-bottom:26px}
|
| 4 |
+
.dash-head h1{font-size:32px;font-weight:700;letter-spacing:-.02em}
|
| 5 |
+
.dash-head p{color:var(--text-2);margin-top:6px}
|
| 6 |
+
|
| 7 |
+
.metrics{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-bottom:20px}
|
| 8 |
+
.metric{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);
|
| 9 |
+
box-shadow:var(--shadow);padding:20px;display:flex;align-items:center;gap:14px}
|
| 10 |
+
.m-i{width:48px;height:48px;border-radius:14px;display:grid;place-items:center;font-size:24px;flex-shrink:0}
|
| 11 |
+
.m-i.blue{background:#E6F1FB;color:#185FA5}.m-i.red{background:var(--danger-soft);color:var(--danger)}
|
| 12 |
+
.m-i.green{background:var(--brand-soft);color:var(--brand-d)}.m-i.teal{background:#E1F5EE;color:#0F6E56}
|
| 13 |
+
.metric b{font-size:26px;font-weight:700;display:block;line-height:1.1}
|
| 14 |
+
.metric span{font-size:13px;color:var(--text-3)}
|
| 15 |
+
|
| 16 |
+
.dash-grid{display:grid;grid-template-columns:1fr 1.1fr;gap:18px}
|
| 17 |
+
.panel{padding:24px}
|
| 18 |
+
.panel h3{font-size:17px;font-weight:600;margin-bottom:18px}
|
| 19 |
+
|
| 20 |
+
.dist .row{margin-bottom:14px}
|
| 21 |
+
.dist .row .top{display:flex;justify-content:space-between;font-size:13.5px;margin-bottom:5px}
|
| 22 |
+
.dist .row .top b{font-weight:600}
|
| 23 |
+
.dist .bar{height:8px;border-radius:999px;background:var(--surface-2);overflow:hidden}
|
| 24 |
+
.dist .bar i{display:block;height:100%;border-radius:999px;transition:width .8s var(--ease)}
|
| 25 |
+
.dist .g0 i{background:var(--brand)}.dist .g1 i,.dist .g2 i{background:var(--warn)}
|
| 26 |
+
.dist .g3 i,.dist .g4 i{background:var(--danger)}
|
| 27 |
+
|
| 28 |
+
.hist{display:flex;flex-direction:column;gap:9px;max-height:340px;overflow:auto}
|
| 29 |
+
.hist .h-row{display:flex;align-items:center;gap:12px;padding:11px 14px;border-radius:13px;background:var(--surface-2)}
|
| 30 |
+
.hist .h-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}
|
| 31 |
+
.hist .h-dot.bad{background:var(--danger)}.hist .h-dot.ok{background:var(--brand)}
|
| 32 |
+
.hist .h-row .g{flex:1;font-size:14px;font-weight:500}
|
| 33 |
+
.hist .h-row .t{font-size:12px;color:var(--text-3)}
|
| 34 |
+
.hist .h-row .r{font-size:13px;font-weight:600}
|
| 35 |
+
.hist .empty{color:var(--text-3);text-align:center;padding:30px;font-size:14px}
|
| 36 |
+
|
| 37 |
+
@media(max-width:820px){.metrics{grid-template-columns:1fr 1fr}.dash-grid{grid-template-columns:1fr}}
|
dashboard.html
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="th">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>RetinaPlus</title>
|
| 7 |
+
<link rel="icon" href="icon.png">
|
| 8 |
+
<link rel="stylesheet" href="shared.css">
|
| 9 |
+
<link rel="stylesheet" href="dashboard.css">
|
| 10 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@3.3.0/dist/tabler-icons.min.css">
|
| 11 |
+
</head>
|
| 12 |
+
<body>
|
| 13 |
+
<nav class="nav">
|
| 14 |
+
<a class="brand" href="/"><img src="icon.png" class="logo-img" alt="RetinaPlus"><span class="brand-name">Retina<b>Plus</b></span></a>
|
| 15 |
+
<div class="nav-links">
|
| 16 |
+
<a href="/" data-th="หน้าแรก" data-en="Home">หน้าแรก</a>
|
| 17 |
+
<a href="/detect" data-th="ตรวจ" data-en="Screen">ตรวจ</a>
|
| 18 |
+
<a href="/dashboard" class="active" data-th="แดชบอร์ด" data-en="Dashboard">แดชบอร์ด</a>
|
| 19 |
+
<div class="nav-tools">
|
| 20 |
+
<button class="tool-btn" data-tool="theme" onclick="toggleTheme()" aria-label="theme"><i class="ti ti-moon"></i></button>
|
| 21 |
+
<button class="tool-btn lang" data-tool="lang" onclick="toggleLang()">EN</button>
|
| 22 |
+
</div>
|
| 23 |
+
</div>
|
| 24 |
+
</nav>
|
| 25 |
+
|
| 26 |
+
<main class="container dash">
|
| 27 |
+
<div class="dash-head reveal"><h1 data-th="แดชบอร์ด" data-en="Dashboard">แดชบอร์ด</h1>
|
| 28 |
+
<p data-th="สรุปผลการคัดกรองทั้งหมดในระบบ" data-en="Summary of all screenings">สรุปผลการคัดกรองทั้งหมดในระบบ</p></div>
|
| 29 |
+
|
| 30 |
+
<div class="metrics reveal d1">
|
| 31 |
+
<div class="metric"><span class="m-i blue"><i class="ti ti-photo"></i></span>
|
| 32 |
+
<div><b id="mTotal">0</b><span data-th="ตรวจทั้งหมด" data-en="Total scans">ตรวจทั้งหมด</span></div></div>
|
| 33 |
+
<div class="metric"><span class="m-i red"><i class="ti ti-alert-triangle"></i></span>
|
| 34 |
+
<div><b id="mRefer">0</b><span data-th="ควรพบแพทย์" data-en="Refer">ควรพบแพทย์</span></div></div>
|
| 35 |
+
<div class="metric"><span class="m-i green"><i class="ti ti-circle-check"></i></span>
|
| 36 |
+
<div><b id="mNormal">0</b><span data-th="ปกติ" data-en="Normal">ปกติ</span></div></div>
|
| 37 |
+
<div class="metric"><span class="m-i teal"><i class="ti ti-percentage"></i></span>
|
| 38 |
+
<div><b id="mRate">0%</b><span data-th="อัตราส่งต่อ" data-en="Referral rate">อัตราส่งต่อ</span></div></div>
|
| 39 |
+
</div>
|
| 40 |
+
|
| 41 |
+
<div class="dash-grid">
|
| 42 |
+
<div class="card panel reveal d2"><h3 data-th="การกระจายระดับความรุนแรง" data-en="Severity distribution">การกระจายระดับความรุนแรง</h3>
|
| 43 |
+
<div id="dist" class="dist"></div></div>
|
| 44 |
+
<div class="card panel reveal d3"><h3 data-th="ประวัติล่าสุด" data-en="Recent history">ประวัติล่าสุด</h3>
|
| 45 |
+
<div id="hist" class="hist"></div></div>
|
| 46 |
+
</div>
|
| 47 |
+
</main>
|
| 48 |
+
|
| 49 |
+
<footer class="footer">
|
| 50 |
+
<span class="footer-brand"><img src="icon.png" class="logo-img" alt="RetinaPlus">Retina<b>Plus</b></span>
|
| 51 |
+
<span style="font-size:12px;opacity:.75">© 2025 RetinaPlus · <span data-th="พัฒนาโดย Nathakorn" data-en="Developed by Nathakorn">พัฒนาโดย Nathakorn</span></span>
|
| 52 |
+
</footer>
|
| 53 |
+
<script src="shared.js"></script>
|
| 54 |
+
<script src="dashboard.js"></script>
|
| 55 |
+
</body>
|
| 56 |
+
</html>
|
dashboard.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const STAGES = ["No DR", "Mild", "Moderate", "Severe", "Proliferative"];
|
| 2 |
+
|
| 3 |
+
Promise.all([
|
| 4 |
+
fetch('/stats').then(r => r.json()),
|
| 5 |
+
fetch('/history').then(r => r.json())
|
| 6 |
+
]).then(([s, h]) => {
|
| 7 |
+
document.getElementById('mTotal').textContent = s.total;
|
| 8 |
+
document.getElementById('mRefer').textContent = s.referable;
|
| 9 |
+
document.getElementById('mNormal').textContent = s.normal;
|
| 10 |
+
document.getElementById('mRate').textContent = (s.total ? Math.round(s.referable / s.total * 100) : 0) + '%';
|
| 11 |
+
|
| 12 |
+
const max = Math.max(1, ...STAGES.map(c => s.dist[c] || 0));
|
| 13 |
+
document.getElementById('dist').innerHTML = STAGES.map((c, i) => {
|
| 14 |
+
const v = s.dist[c] || 0;
|
| 15 |
+
return `<div class="row g${i}"><div class="top"><span>${c}</span><b>${v}</b></div>
|
| 16 |
+
<div class="bar"><i style="width:${v / max * 100}%"></i></div></div>`;
|
| 17 |
+
}).join('');
|
| 18 |
+
|
| 19 |
+
const hist = document.getElementById('hist');
|
| 20 |
+
if (!h.length) { hist.innerHTML = '<div class="empty">ยังไม่มีประวัติการตรวจ</div>'; return; }
|
| 21 |
+
hist.innerHTML = h.slice(0, 30).map(x => `
|
| 22 |
+
<div class="h-row"><span class="h-dot ${x.referable ? 'bad' : 'ok'}"></span>
|
| 23 |
+
<span class="g">${x.grade_name}</span>
|
| 24 |
+
<span class="t">${(x.time || '').replace('T', ' ')}</span>
|
| 25 |
+
<span class="r" style="color:${x.referable ? 'var(--danger)' : 'var(--brand)'}">${x.risk_percent}%</span></div>`).join('');
|
| 26 |
+
}).catch(() => {
|
| 27 |
+
document.getElementById('hist').innerHTML = '<div class="empty">โหลดข้อมูลไม่สำเร็จ</div>';
|
| 28 |
+
});
|
detect.css
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* RetinaPlus — detect page */
|
| 2 |
+
.det{padding:40px 24px 60px;max-width:760px;position:relative;z-index:1}
|
| 3 |
+
.det-head{text-align:center;margin-bottom:28px}
|
| 4 |
+
.det-head h1{font-size:32px;font-weight:700;letter-spacing:-.02em}
|
| 5 |
+
.det-head p{color:var(--text-2);margin-top:8px}
|
| 6 |
+
.det-head .pill{margin-top:14px}
|
| 7 |
+
|
| 8 |
+
/* ===================== SPLASH — theme-aware, smooth rings ===================== */
|
| 9 |
+
.splash{
|
| 10 |
+
position:fixed;inset:0;z-index:300;
|
| 11 |
+
background:var(--bg);
|
| 12 |
+
display:grid;place-items:center;
|
| 13 |
+
animation:splashOut .7s cubic-bezier(.4,0,.2,1) 1.7s forwards;
|
| 14 |
+
overflow:hidden;
|
| 15 |
+
}
|
| 16 |
+
/* subtle center glow that matches theme */
|
| 17 |
+
.splash-bg{
|
| 18 |
+
position:absolute;inset:0;pointer-events:none;
|
| 19 |
+
background:radial-gradient(ellipse 55% 45% at 50% 50%,var(--brand-soft),transparent 68%);
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
.splash-inner{
|
| 23 |
+
position:relative;display:flex;flex-direction:column;align-items:center;gap:32px;
|
| 24 |
+
animation:splashIn .65s cubic-bezier(.22,.61,.36,1) both;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/* rings — emanate from center, smooth scale, no position jump */
|
| 28 |
+
.splash-rings{
|
| 29 |
+
position:absolute;top:50%;left:50%;
|
| 30 |
+
width:0;height:0;
|
| 31 |
+
pointer-events:none;
|
| 32 |
+
}
|
| 33 |
+
.sring{
|
| 34 |
+
position:absolute;border-radius:50%;
|
| 35 |
+
border:1.5px solid var(--brand);
|
| 36 |
+
opacity:0;
|
| 37 |
+
width:20px;height:20px;
|
| 38 |
+
margin:-10px 0 0 -10px;
|
| 39 |
+
will-change:transform,opacity;
|
| 40 |
+
}
|
| 41 |
+
.sring.s1{animation:ringSmooth 2.4s cubic-bezier(.15,.5,.35,1) .0s infinite}
|
| 42 |
+
.sring.s2{animation:ringSmooth 2.4s cubic-bezier(.15,.5,.35,1) .8s infinite}
|
| 43 |
+
.sring.s3{animation:ringSmooth 2.4s cubic-bezier(.15,.5,.35,1) 1.6s infinite}
|
| 44 |
+
|
| 45 |
+
@keyframes ringSmooth{
|
| 46 |
+
0% {transform:scale(1); opacity:.6}
|
| 47 |
+
70% {opacity:.15}
|
| 48 |
+
100%{transform:scale(22); opacity:0}
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/* eye icon — reads on both themes, no plate needed */
|
| 52 |
+
.splash-logo-wrap{
|
| 53 |
+
position:relative;z-index:2;
|
| 54 |
+
display:flex;align-items:center;justify-content:center;
|
| 55 |
+
filter:drop-shadow(0 18px 44px rgba(59,155,240,.38));
|
| 56 |
+
animation:logoPop .8s cubic-bezier(.22,.61,.36,1) .1s both;
|
| 57 |
+
}
|
| 58 |
+
.splash-logo{
|
| 59 |
+
height:168px;width:168px;
|
| 60 |
+
object-fit:contain;display:block;
|
| 61 |
+
}
|
| 62 |
+
@keyframes logoPop{
|
| 63 |
+
0% {opacity:0;transform:scale(.76) translateY(14px)}
|
| 64 |
+
62% {transform:scale(1.03) translateY(-3px)}
|
| 65 |
+
100%{opacity:1;transform:scale(1) translateY(0)}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/* status pill */
|
| 69 |
+
.splash-label{
|
| 70 |
+
display:flex;align-items:center;gap:9px;
|
| 71 |
+
animation:splashFade .55s var(--ease) .5s both;
|
| 72 |
+
z-index:2;
|
| 73 |
+
background:var(--surface);
|
| 74 |
+
padding:9px 20px;
|
| 75 |
+
border-radius:999px;
|
| 76 |
+
border:1px solid var(--line);
|
| 77 |
+
box-shadow:var(--shadow);
|
| 78 |
+
}
|
| 79 |
+
.splash-dot{
|
| 80 |
+
width:8px;height:8px;border-radius:50%;
|
| 81 |
+
background:var(--brand);
|
| 82 |
+
box-shadow:0 0 7px var(--brand);
|
| 83 |
+
flex-shrink:0;
|
| 84 |
+
animation:dotBlink 1.3s ease-in-out infinite;
|
| 85 |
+
}
|
| 86 |
+
@keyframes dotBlink{0%,100%{opacity:1}50%{opacity:.2}}
|
| 87 |
+
.splash-txt{
|
| 88 |
+
font-size:14px;
|
| 89 |
+
color:var(--text);
|
| 90 |
+
font-weight:500;
|
| 91 |
+
letter-spacing:.015em;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
@keyframes splashIn {from{opacity:0;transform:scale(.93)}to{opacity:1;transform:none}}
|
| 95 |
+
@keyframes splashFade {from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
|
| 96 |
+
@keyframes splashOut {to{opacity:0;visibility:hidden;pointer-events:none}}
|
| 97 |
+
/* =========================================================================== */
|
| 98 |
+
|
| 99 |
+
.verdict.warn .vi{background:var(--warn-soft);color:var(--warn)}
|
| 100 |
+
.verdict.warn .vp b{color:var(--warn)}
|
| 101 |
+
|
| 102 |
+
/* chooser tabs */
|
| 103 |
+
.chooser{display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:8px;margin-bottom:16px}
|
| 104 |
+
.choice{display:flex;align-items:center;justify-content:center;gap:8px;padding:14px;border-radius:var(--r);
|
| 105 |
+
border:none;background:transparent;color:var(--text-2);font-weight:600;font-size:15px;cursor:pointer;
|
| 106 |
+
font-family:inherit;transition:.2s var(--ease)}
|
| 107 |
+
.choice i{font-size:20px}
|
| 108 |
+
.choice:hover{background:var(--surface-2)}
|
| 109 |
+
.choice.active{background:var(--brand-soft);color:var(--brand-d)}
|
| 110 |
+
|
| 111 |
+
/* camera */
|
| 112 |
+
.camera{padding:14px;animation:pop .3s var(--ease)}
|
| 113 |
+
.cam-stage{position:relative;border-radius:var(--r-lg);overflow:hidden;background:#0a0e14;aspect-ratio:4/3}
|
| 114 |
+
.cam-stage video{width:100%;height:100%;object-fit:cover;display:block}
|
| 115 |
+
.eye-frame{position:absolute;inset:0;pointer-events:none}
|
| 116 |
+
.eye-frame .ring{position:absolute;left:50%;top:50%;width:54%;aspect-ratio:1;transform:translate(-50%,-50%);
|
| 117 |
+
border:2px solid rgba(120,190,255,.85);border-radius:50%;box-shadow:0 0 0 100vmax rgba(0,0,0,.35)}
|
| 118 |
+
.eye-frame .cross-h,.eye-frame .cross-v{position:absolute;left:50%;top:50%;background:rgba(120,190,255,.6)}
|
| 119 |
+
.eye-frame .cross-h{width:26px;height:2px;transform:translate(-50%,-50%)}
|
| 120 |
+
.eye-frame .cross-v{width:2px;height:26px;transform:translate(-50%,-50%)}
|
| 121 |
+
.eye-frame .bk{position:absolute;width:26px;height:26px;border:3px solid rgba(120,190,255,.9)}
|
| 122 |
+
.eye-frame .tl{left:16px;top:16px;border-right:0;border-bottom:0;border-radius:6px 0 0 0}
|
| 123 |
+
.eye-frame .tr{right:16px;top:16px;border-left:0;border-bottom:0;border-radius:0 6px 0 0}
|
| 124 |
+
.eye-frame .bl{left:16px;bottom:16px;border-right:0;border-top:0;border-radius:0 0 0 6px}
|
| 125 |
+
.eye-frame .br{right:16px;bottom:16px;border-left:0;border-top:0;border-radius:0 0 6px 0}
|
| 126 |
+
.cam-hint{position:absolute;bottom:14px;left:50%;transform:translateX(-50%);background:rgba(0,0,0,.55);
|
| 127 |
+
color:#fff;font-size:13px;padding:6px 14px;border-radius:999px;white-space:nowrap}
|
| 128 |
+
.cam-bar{display:flex;align-items:center;justify-content:space-between;padding:16px 8px 6px}
|
| 129 |
+
.shutter{width:66px;height:66px;border-radius:50%;border:4px solid var(--brand);background:transparent;
|
| 130 |
+
cursor:pointer;display:grid;place-items:center;transition:.15s var(--ease)}
|
| 131 |
+
.shutter span{width:50px;height:50px;border-radius:50%;background:var(--brand);transition:.15s var(--ease)}
|
| 132 |
+
.shutter:active span{transform:scale(.85)}
|
| 133 |
+
|
| 134 |
+
.upload{padding:14px}
|
| 135 |
+
.drop{border:2px dashed var(--line);border-radius:var(--r-lg);padding:54px 24px;text-align:center;
|
| 136 |
+
transition:.25s var(--ease);cursor:pointer}
|
| 137 |
+
.drop.over{border-color:var(--brand);background:var(--brand-soft)}
|
| 138 |
+
.drop-i{width:70px;height:70px;border-radius:20px;background:var(--brand-soft);color:var(--brand-d);
|
| 139 |
+
display:grid;place-items:center;font-size:34px;margin:0 auto 16px}
|
| 140 |
+
.drop h3{font-size:18px;font-weight:600}
|
| 141 |
+
.drop p{color:var(--text-3);font-size:14px;margin:6px 0 18px}
|
| 142 |
+
|
| 143 |
+
.loading{padding:54px;text-align:center;animation:pop .4s var(--ease)}
|
| 144 |
+
.loading h3{font-size:19px;margin-top:18px}
|
| 145 |
+
.loading p{color:var(--text-2)}
|
| 146 |
+
.spinner{width:46px;height:46px;border-radius:50%;margin:0 auto;
|
| 147 |
+
border:4px solid var(--brand-soft);border-top-color:var(--brand);animation:spin .8s linear infinite}
|
| 148 |
+
|
| 149 |
+
.result{display:flex;flex-direction:column;gap:16px}
|
| 150 |
+
.result>*{animation:fadeUp .5s var(--ease) both}
|
| 151 |
+
.result>*:nth-child(2){animation-delay:.06s}.result>*:nth-child(3){animation-delay:.12s}
|
| 152 |
+
.result>*:nth-child(4){animation-delay:.18s}.result>*:nth-child(5){animation-delay:.24s}
|
| 153 |
+
|
| 154 |
+
.verdict{display:flex;align-items:center;gap:16px;padding:22px 24px}
|
| 155 |
+
.verdict .vi{width:56px;height:56px;border-radius:17px;display:grid;place-items:center;font-size:30px;flex-shrink:0}
|
| 156 |
+
.verdict.bad .vi{background:var(--danger-soft);color:var(--danger)}
|
| 157 |
+
.verdict.ok .vi{background:var(--brand-soft);color:var(--brand-d)}
|
| 158 |
+
.verdict .vt{flex:1}
|
| 159 |
+
.verdict .vt h2{font-size:21px;font-weight:700;letter-spacing:-.01em}
|
| 160 |
+
.verdict .vt p{color:var(--text-2);font-size:14.5px}
|
| 161 |
+
.verdict .vp{text-align:center}
|
| 162 |
+
.verdict .vp b{font-size:30px;font-weight:700;display:block;line-height:1}
|
| 163 |
+
.verdict.bad .vp b{color:var(--danger)}.verdict.ok .vp b{color:var(--brand-d)}
|
| 164 |
+
.verdict .vp span{font-size:12px;color:var(--text-3)}
|
| 165 |
+
|
| 166 |
+
.lbl{font-size:13px;color:var(--text-2);font-weight:500;display:flex;align-items:center;gap:6px}
|
| 167 |
+
.stage-card{padding:20px 22px}
|
| 168 |
+
.stages{display:grid;grid-template-columns:repeat(5,1fr);gap:7px;margin:12px 0 16px}
|
| 169 |
+
.stages .st{text-align:center;padding:9px 4px;border-radius:11px;background:var(--surface-2);
|
| 170 |
+
font-size:12px;color:var(--text-3);transition:.3s var(--ease)}
|
| 171 |
+
.stages .st.on{font-weight:600;transform:translateY(-2px)}
|
| 172 |
+
.stages .st.on.g0{background:var(--brand-soft);color:var(--brand-d);box-shadow:inset 0 0 0 2px var(--brand)}
|
| 173 |
+
.stages .st.on.g1,.stages .st.on.g2{background:var(--warn-soft);color:var(--warn);box-shadow:inset 0 0 0 2px var(--warn)}
|
| 174 |
+
.stages .st.on.g3,.stages .st.on.g4{background:var(--danger-soft);color:var(--danger);box-shadow:inset 0 0 0 2px var(--danger)}
|
| 175 |
+
.scorebar{height:9px;border-radius:999px;background:var(--surface-2);overflow:hidden}
|
| 176 |
+
.scorebar-fill{height:100%;width:0;border-radius:999px;
|
| 177 |
+
background:linear-gradient(90deg,var(--brand),var(--warn),var(--danger));transition:width 1s var(--ease)}
|
| 178 |
+
.score-meta{display:flex;justify-content:space-between;font-size:12px;color:var(--text-3);margin-top:7px}
|
| 179 |
+
.score-meta #scoreVal{font-weight:600;color:var(--text)}
|
| 180 |
+
|
| 181 |
+
.img-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}
|
| 182 |
+
.img-cell{padding:14px}
|
| 183 |
+
.img-cell img{width:100%;border-radius:var(--r);margin-top:10px;background:#111;aspect-ratio:1}
|
| 184 |
+
.cam-note{display:block;font-size:11.5px;color:var(--text-3);margin-top:8px}
|
| 185 |
+
|
| 186 |
+
.why{padding:18px 20px;display:flex;gap:12px;background:var(--brand-soft);border-color:transparent}
|
| 187 |
+
.why i{font-size:22px;color:var(--brand-d);flex-shrink:0}
|
| 188 |
+
.why .wt{font-size:14.5px;color:var(--brand-d);line-height:1.6}
|
| 189 |
+
.why .wt b{font-weight:600}
|
| 190 |
+
|
| 191 |
+
.disclaimer{padding:14px 18px;display:flex;gap:10px;align-items:center;font-size:13px;color:var(--text-2);background:var(--surface-2);border-color:transparent}
|
| 192 |
+
.disclaimer i{font-size:18px;color:var(--text-3)}
|
| 193 |
+
|
| 194 |
+
.act{display:flex;gap:12px;justify-content:center;margin-top:6px}
|
| 195 |
+
|
| 196 |
+
@media(max-width:620px){.img-grid{grid-template-columns:1fr}.stages{gap:5px}.stages .st{font-size:10.5px}.act{flex-direction:column}}
|
| 197 |
+
|
| 198 |
+
/* page glow decoration (behind content) */
|
| 199 |
+
.page-glow{position:fixed;inset:0;z-index:0;overflow:hidden;pointer-events:none}
|
| 200 |
+
.footer{position:relative;z-index:1}
|
| 201 |
+
|
| 202 |
+
/* photo tips row */
|
| 203 |
+
.tips-row{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-top:24px;position:relative;z-index:1}
|
| 204 |
+
.tip{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:20px 16px;
|
| 205 |
+
text-align:center;box-shadow:var(--shadow);transition:.25s var(--ease)}
|
| 206 |
+
.tip:hover{transform:translateY(-3px);border-color:var(--brand);box-shadow:var(--shadow-lg)}
|
| 207 |
+
.tip i{font-size:26px;color:var(--brand);display:block;margin-bottom:9px}
|
| 208 |
+
.tip b{display:block;font-size:14.5px;font-weight:700;margin-bottom:3px;color:var(--text)}
|
| 209 |
+
.tip span{font-size:12.5px;color:var(--text-2);line-height:1.5}
|
| 210 |
+
@media(max-width:600px){.tips-row{grid-template-columns:1fr}}
|
detect.html
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="th">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>RetinaPlus</title>
|
| 7 |
+
<link rel="icon" href="icon.png">
|
| 8 |
+
<link rel="stylesheet" href="shared.css">
|
| 9 |
+
<link rel="stylesheet" href="detect.css">
|
| 10 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@3.3.0/dist/tabler-icons.min.css">
|
| 11 |
+
</head>
|
| 12 |
+
<body>
|
| 13 |
+
<div id="splash" class="splash">
|
| 14 |
+
<div class="splash-bg"></div>
|
| 15 |
+
<div class="splash-rings">
|
| 16 |
+
<span class="sring s1"></span>
|
| 17 |
+
<span class="sring s2"></span>
|
| 18 |
+
<span class="sring s3"></span>
|
| 19 |
+
</div>
|
| 20 |
+
<div class="splash-inner">
|
| 21 |
+
<div class="splash-logo-wrap">
|
| 22 |
+
<img src="icon.png" class="splash-logo" alt="RetinaPlus">
|
| 23 |
+
</div>
|
| 24 |
+
<div class="splash-label">
|
| 25 |
+
<span class="splash-dot"></span>
|
| 26 |
+
<span class="splash-txt" data-th="กำลังเตรียมระบบตรวจ" data-en="Preparing scanner">กำลังเตรียมระบบตรวจ</span>
|
| 27 |
+
</div>
|
| 28 |
+
</div>
|
| 29 |
+
</div>
|
| 30 |
+
<nav class="nav">
|
| 31 |
+
<a class="brand" href="/"><img src="icon.png" class="logo-img" alt="RetinaPlus"><span class="brand-name">Retina<b>Plus</b></span></a>
|
| 32 |
+
<div class="nav-links">
|
| 33 |
+
<a href="/" data-th="หน้าแรก" data-en="Home">หน้าแรก</a>
|
| 34 |
+
<a href="/detect" class="active" data-th="ตรวจ" data-en="Screen">ตรวจ</a>
|
| 35 |
+
<a href="/dashboard" data-th="แดชบอร์ด" data-en="Dashboard">แดชบอร์ด</a>
|
| 36 |
+
<div class="nav-tools">
|
| 37 |
+
<button class="tool-btn" data-tool="theme" onclick="toggleTheme()" aria-label="theme"><i class="ti ti-moon"></i></button>
|
| 38 |
+
<button class="tool-btn lang" data-tool="lang" onclick="toggleLang()">EN</button>
|
| 39 |
+
</div>
|
| 40 |
+
</div>
|
| 41 |
+
</nav>
|
| 42 |
+
|
| 43 |
+
<div class="page-glow">
|
| 44 |
+
<span class="glow a" style="width:460px;height:460px;top:-120px;right:-100px"></span>
|
| 45 |
+
<span class="glow b" style="width:380px;height:380px;bottom:-140px;left:-120px"></span>
|
| 46 |
+
</div>
|
| 47 |
+
|
| 48 |
+
<main class="container det">
|
| 49 |
+
<div class="det-head reveal">
|
| 50 |
+
<h1 data-th="ตรวจคัดกรองเบาหวานขึ้นจอตา" data-en="Diabetic retinopathy screening">ตรวจคัดกรองเบาหวานขึ้นจอตา</h1>
|
| 51 |
+
<p data-th="ถ่ายภาพจอตาสด หรืออัปโหลดไฟล์ภาพ เพื่อให้ AI วิเคราะห์"
|
| 52 |
+
data-en="Capture live or upload a fundus image for AI analysis">ถ่ายภาพจอตาสด หรืออัปโหลดไฟล์ภาพ เพื่อให้ AI วิเคราะห์</p>
|
| 53 |
+
<span id="modeTag" class="pill pill-warn" style="display:none"><i class="ti ti-flask"></i>
|
| 54 |
+
<span data-th="โหมดสาธิต" data-en="Demo mode">โหมดสาธิต</span></span>
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
<!-- choose: camera or upload -->
|
| 58 |
+
<div id="chooser" class="card chooser reveal d1">
|
| 59 |
+
<button class="choice" id="tabCam"><i class="ti ti-camera"></i>
|
| 60 |
+
<span data-th="ถ่ายภาพสด" data-en="Take photo">ถ่ายภาพสด</span></button>
|
| 61 |
+
<button class="choice active" id="tabUp"><i class="ti ti-upload"></i>
|
| 62 |
+
<span data-th="อัปโหลดไฟล์" data-en="Upload file">อัปโหลดไฟล์</span></button>
|
| 63 |
+
</div>
|
| 64 |
+
|
| 65 |
+
<!-- upload panel -->
|
| 66 |
+
<div id="upPanel" class="card upload reveal d2">
|
| 67 |
+
<input type="file" id="file" accept="image/*" hidden>
|
| 68 |
+
<div class="drop" id="drop">
|
| 69 |
+
<span class="drop-i"><i class="ti ti-photo-up"></i></span>
|
| 70 |
+
<h3 data-th="ลากภาพมาวาง หรือคลิกเพื่อเลือก" data-en="Drag an image here or click to choose">ลากภาพมาวาง หรือคลิกเพื่อเลือก</h3>
|
| 71 |
+
<p data-th="รองรับ JPG · PNG — ภาพถ่ายจอตา" data-en="JPG · PNG — fundus image">รองรับ JPG · PNG — ภาพถ่ายจอตา</p>
|
| 72 |
+
<button class="btn btn-primary" id="pickBtn"><i class="ti ti-folder-open"></i>
|
| 73 |
+
<span data-th="เลือกภาพ" data-en="Choose image">เลือกภาพ</span></button>
|
| 74 |
+
</div>
|
| 75 |
+
</div>
|
| 76 |
+
|
| 77 |
+
<!-- camera panel -->
|
| 78 |
+
<div id="camPanel" class="card camera" style="display:none">
|
| 79 |
+
<div class="cam-stage">
|
| 80 |
+
<video id="video" autoplay playsinline muted></video>
|
| 81 |
+
<div class="eye-frame">
|
| 82 |
+
<span class="bk tl"></span><span class="bk tr"></span><span class="bk bl"></span><span class="bk br"></span>
|
| 83 |
+
<div class="ring"></div><div class="cross-h"></div><div class="cross-v"></div>
|
| 84 |
+
</div>
|
| 85 |
+
<div class="cam-hint" data-th="จัดดวงตา/จอตาให้อยู่ในกรอบ" data-en="Align the eye inside the frame">จัดดวงตา/จอตาให้อยู่ในกรอบ</div>
|
| 86 |
+
</div>
|
| 87 |
+
<div class="cam-bar">
|
| 88 |
+
<button class="tool-btn" id="flip" aria-label="flip"><i class="ti ti-camera-rotate"></i></button>
|
| 89 |
+
<button class="shutter" id="snap" aria-label="capture"><span></span></button>
|
| 90 |
+
<span style="width:38px"></span>
|
| 91 |
+
</div>
|
| 92 |
+
<canvas id="canvas" hidden></canvas>
|
| 93 |
+
</div>
|
| 94 |
+
|
| 95 |
+
<!-- loading -->
|
| 96 |
+
<div id="loading" class="card loading" style="display:none">
|
| 97 |
+
<div class="spinner"></div>
|
| 98 |
+
<h3 data-th="กำลังวิเคราะห์…" data-en="Analyzing…">กำลังวิเคราะห์…</h3>
|
| 99 |
+
<p data-th="ประมวลผลภายในไม่กี่วินาที" data-en="Processing in seconds">ประมวลผลภายในไม่กี่วินาที</p>
|
| 100 |
+
</div>
|
| 101 |
+
|
| 102 |
+
<!-- result -->
|
| 103 |
+
<div id="result" class="result" style="display:none">
|
| 104 |
+
<div id="verdict" class="card verdict"></div>
|
| 105 |
+
<div class="card stage-card">
|
| 106 |
+
<div class="lbl" data-th="ระดับความรุนแรง (โดยประมาณ)" data-en="Estimated severity">ระดับความรุนแรง (โดยประมาณ)</div>
|
| 107 |
+
<div class="stages" id="stages"></div>
|
| 108 |
+
<div class="scorebar"><div class="scorebar-fill" id="scoreFill"></div></div>
|
| 109 |
+
<div class="score-meta"><span>No DR</span><span id="scoreVal">score 0.0</span><span>Proliferative</span></div>
|
| 110 |
+
</div>
|
| 111 |
+
<div class="img-grid">
|
| 112 |
+
<div class="card img-cell"><div class="lbl"><i class="ti ti-photo"></i> <span data-th="ภาพที่ประมวลผล" data-en="Processed image">ภาพที่ประมวลผล</span></div><img id="imgPre" alt=""></div>
|
| 113 |
+
<div class="card img-cell"><div class="lbl"><i class="ti ti-flare"></i> <span data-th="บริเวณที่ AI วิเคราะห์" data-en="AI focus region">บริเวณที่ AI วิเคราะห์</span></div><img id="imgCam" alt=""><span class="cam-note" data-th="สีร้อน = AI ให้ความสำคัญ" data-en="Warm = AI attention">สีร้อน = AI ให้ความสำคัญ</span></div>
|
| 114 |
+
</div>
|
| 115 |
+
<div id="why" class="card why"></div>
|
| 116 |
+
<div class="card disclaimer"><i class="ti ti-info-circle"></i>
|
| 117 |
+
<span data-th="เครื่องมือคัดกรองเบื้องต้น ผลควรได้รับการยืนยันโดยจักษุแพทย์" data-en="A screening aid — confirm with an ophthalmologist.">เครื่องมือคัดกรองเบื้องต้น ผลควรได้รับการยืนยันโดยจักษุแพทย์</span></div>
|
| 118 |
+
<div class="act">
|
| 119 |
+
<button class="btn btn-ghost" id="again"><i class="ti ti-refresh"></i> <span data-th="ตรวจใหม่" data-en="Scan again">ตรวจใหม่</span></button>
|
| 120 |
+
<button class="btn btn-primary" id="send"><i class="ti ti-send"></i> <span data-th="ส่งให้แพทย์" data-en="Send to doctor">ส่งให้แพทย์</span></button>
|
| 121 |
+
</div>
|
| 122 |
+
</div>
|
| 123 |
+
|
| 124 |
+
<div class="tips-row reveal d3">
|
| 125 |
+
<div class="tip"><i class="ti ti-bulb"></i>
|
| 126 |
+
<b data-th="แสงสว่างพอ" data-en="Good lighting">แสงสว่างพอ</b>
|
| 127 |
+
<span data-th="ถ่ายในที่มีแสงเพียงพอ ไม่ย้อนแสง" data-en="Shoot in even, bright light">ถ่ายในที่มีแสงเพียงพอ</span></div>
|
| 128 |
+
<div class="tip"><i class="ti ti-focus-2"></i>
|
| 129 |
+
<b data-th="โฟกัสให้ชัด" data-en="Sharp focus">โฟกัสให้ชัด</b>
|
| 130 |
+
<span data-th="จัดจอตาให้อยู่กลางเฟรมและคมชัด" data-en="Center the retina, keep it sharp">จัดจอตาให้อยู่กลางเฟรม</span></div>
|
| 131 |
+
<div class="tip"><i class="ti ti-photo-check"></i>
|
| 132 |
+
<b data-th="ใช้ภาพจอตาจริง" data-en="Real fundus image">ใช้ภาพจอตาจริง</b>
|
| 133 |
+
<span data-th="รองรับเฉพาะภาพถ่ายจอประสาทตา (fundus)" data-en="Fundus photographs only">รองรับเฉพาะภาพถ่ายจอตา</span></div>
|
| 134 |
+
</div>
|
| 135 |
+
</main>
|
| 136 |
+
|
| 137 |
+
<footer class="footer">
|
| 138 |
+
<span class="footer-brand"><img src="icon.png" class="logo-img" alt="RetinaPlus">Retina<b>Plus</b></span>
|
| 139 |
+
<span style="font-size:12px;opacity:.75">© 2025 RetinaPlus · <span data-th="พัฒนาโดย Nathakorn" data-en="Developed by Nathakorn">พัฒนาโดย Nathakorn</span></span>
|
| 140 |
+
</footer>
|
| 141 |
+
<script src="shared.js"></script>
|
| 142 |
+
<script src="detect.js"></script>
|
| 143 |
+
</body>
|
| 144 |
+
</html>
|
detect.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const $ = s => document.querySelector(s);
|
| 2 |
+
const STAGES = { th: ["No DR", "Mild", "Moderate", "Severe", "Proliferative"], en: ["No DR", "Mild", "Moderate", "Severe", "Proliferative"] };
|
| 3 |
+
const TIPS = {
|
| 4 |
+
th: {
|
| 5 |
+
0: 'ไม่พบลักษณะของเบาหวานขึ้นจอตา จอตาและเส้นเลือดอยู่ในเกณฑ์ปกติ',
|
| 6 |
+
1: 'พบสัญญาณเริ่มต้น เช่น microaneurysm เล็กน้อย แนะนำติดตามอาการ',
|
| 7 |
+
2: 'พบลักษณะระดับปานกลาง เช่น hard exudate / จุดเลือดออก',
|
| 8 |
+
3: 'พบความผิดปกติระดับรุนแรง ควรพบจักษุแพทย์โดยเร็ว',
|
| 9 |
+
4: 'พบลักษณะระยะลุกลาม (เส้นเลือดงอกผิดปกติ) ควรพบจักษุแพทย์ทันที'
|
| 10 |
+
},
|
| 11 |
+
en: {
|
| 12 |
+
0: 'No signs of diabetic retinopathy. Retina and vessels appear normal.',
|
| 13 |
+
1: 'Early signs such as a few microaneurysms. Monitoring recommended.',
|
| 14 |
+
2: 'Moderate features such as hard exudates / hemorrhages.',
|
| 15 |
+
3: 'Severe abnormalities. See an ophthalmologist soon.',
|
| 16 |
+
4: 'Proliferative features (abnormal new vessels). See an ophthalmologist now.'
|
| 17 |
+
}
|
| 18 |
+
};
|
| 19 |
+
const T = (th, en) => getLang() === 'en' ? en : th;
|
| 20 |
+
|
| 21 |
+
fetch('/status').then(r => r.json()).then(s => { if (s.demo) $('#modeTag').style.display = 'inline-flex'; }).catch(() => {});
|
| 22 |
+
|
| 23 |
+
// dismiss splash (so it ไม่บัง clicks)
|
| 24 |
+
setTimeout(() => { const s = document.getElementById('splash'); if (s) s.style.display = 'none'; }, 2500);
|
| 25 |
+
|
| 26 |
+
// ---- tabs ----
|
| 27 |
+
let stream = null, facing = 'environment';
|
| 28 |
+
$('#tabUp').onclick = () => { setTab('up'); };
|
| 29 |
+
$('#tabCam').onclick = () => { setTab('cam'); };
|
| 30 |
+
function setTab(t) {
|
| 31 |
+
$('#tabUp').classList.toggle('active', t === 'up');
|
| 32 |
+
$('#tabCam').classList.toggle('active', t === 'cam');
|
| 33 |
+
$('#upPanel').style.display = t === 'up' ? 'block' : 'none';
|
| 34 |
+
$('#camPanel').style.display = t === 'cam' ? 'block' : 'none';
|
| 35 |
+
if (t === 'cam') startCam(); else stopCam();
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
// ---- upload ----
|
| 39 |
+
const drop = $('#drop'), file = $('#file');
|
| 40 |
+
$('#pickBtn').onclick = e => { e.stopPropagation(); file.click(); };
|
| 41 |
+
drop.onclick = e => { if (e.target.id !== 'pickBtn') file.click(); };
|
| 42 |
+
['dragover', 'dragenter'].forEach(ev => drop.addEventListener(ev, e => { e.preventDefault(); drop.classList.add('over'); }));
|
| 43 |
+
['dragleave', 'drop'].forEach(ev => drop.addEventListener(ev, e => { e.preventDefault(); drop.classList.remove('over'); }));
|
| 44 |
+
drop.addEventListener('drop', e => { if (e.dataTransfer.files[0]) analyze(e.dataTransfer.files[0]); });
|
| 45 |
+
file.onchange = () => { if (file.files[0]) analyze(file.files[0]); };
|
| 46 |
+
|
| 47 |
+
// ---- camera ----
|
| 48 |
+
async function startCam() {
|
| 49 |
+
try {
|
| 50 |
+
stopCam();
|
| 51 |
+
stream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: facing, width: { ideal: 1280 } }, audio: false });
|
| 52 |
+
$('#video').srcObject = stream;
|
| 53 |
+
} catch (e) {
|
| 54 |
+
alert(T('เปิดกล้องไม่ได้ — ลองอนุญาตสิทธิ์กล้อง หรือใช้การอัปโหลดแทน', 'Cannot open camera — allow camera permission or use upload.'));
|
| 55 |
+
setTab('up');
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
function stopCam() { if (stream) { stream.getTracks().forEach(t => t.stop()); stream = null; } }
|
| 59 |
+
$('#flip').onclick = () => { facing = facing === 'environment' ? 'user' : 'environment'; startCam(); };
|
| 60 |
+
$('#snap').onclick = () => {
|
| 61 |
+
const v = $('#video'), c = $('#canvas');
|
| 62 |
+
if (!v.videoWidth) return;
|
| 63 |
+
const s = Math.min(v.videoWidth, v.videoHeight); // crop กลางเป็นสี่เหลี่ยม
|
| 64 |
+
c.width = s; c.height = s;
|
| 65 |
+
c.getContext('2d').drawImage(v, (v.videoWidth - s) / 2, (v.videoHeight - s) / 2, s, s, 0, 0, s, s);
|
| 66 |
+
c.toBlob(b => analyze(b), 'image/jpeg', 0.92);
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
// ---- analyze ----
|
| 70 |
+
function show(el) {
|
| 71 |
+
['#chooser', '#upPanel', '#camPanel', '#loading', '#result'].forEach(s => $(s).style.display = 'none');
|
| 72 |
+
if (el === '#result') $(el).style.display = 'flex';
|
| 73 |
+
else if (el === '#loading') $(el).style.display = 'block';
|
| 74 |
+
else { $('#chooser').style.display = 'grid'; $(el).style.display = el === '#camPanel' ? 'block' : 'block'; }
|
| 75 |
+
}
|
| 76 |
+
async function analyze(f) {
|
| 77 |
+
stopCam(); show('#loading');
|
| 78 |
+
const fd = new FormData(); fd.append('image', f);
|
| 79 |
+
try {
|
| 80 |
+
const r = await fetch('/predict', { method: 'POST', body: fd });
|
| 81 |
+
const d = await r.json();
|
| 82 |
+
if (d.error) throw new Error(d.error);
|
| 83 |
+
if (d.not_fundus) renderNotFundus(d); else render(d);
|
| 84 |
+
} catch (e) { alert(T('วิเคราะห์ไม่สำเร็จ: ', 'Failed: ') + e.message); backToChoose(); }
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
function setParts(on) {
|
| 88 |
+
['.stage-card', '.img-grid', '.why', '.disclaimer'].forEach(s => {
|
| 89 |
+
const e = document.querySelector('#result ' + s); if (e) e.style.display = on ? '' : 'none';
|
| 90 |
+
});
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
function renderNotFundus(d) {
|
| 94 |
+
const v = $('#verdict');
|
| 95 |
+
v.className = 'card verdict warn';
|
| 96 |
+
v.innerHTML = `<div class="vi"><i class="ti ti-photo-x"></i></div>
|
| 97 |
+
<div class="vt"><h2>${T('ไม่ใช่ภาพจอประสาทตา', 'Not a fundus image')}</h2>
|
| 98 |
+
<p>${getLang() === 'en' ? d.message_en : d.message_th}</p></div>`;
|
| 99 |
+
setParts(false);
|
| 100 |
+
show('#result');
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
function render(d) {
|
| 104 |
+
setParts(true);
|
| 105 |
+
const v = $('#verdict');
|
| 106 |
+
v.className = 'card verdict ' + (d.referable ? 'bad' : 'ok');
|
| 107 |
+
v.innerHTML = `<div class="vi"><i class="ti ti-${d.referable ? 'alert-triangle' : 'circle-check'}"></i></div>
|
| 108 |
+
<div class="vt"><h2>${d.referable ? T('พบความผิดปกติ — ควรพบจักษุแพทย์', 'Abnormal — see an ophthalmologist') : T('ปกติ — ไม่พบความเสี่ยงที่ต้องส่งต่อ', 'Normal — no referral needed')}</h2>
|
| 109 |
+
<p>${T('ระดับ', 'Level')}: <b>${d.grade_name}</b>${d.demo ? ' · ' + T('สาธิต', 'demo') : ''}</p></div>
|
| 110 |
+
<div class="vp"><b>${d.risk_percent}%</b><span>${T('ความเสี่ยง', 'risk')}</span></div>`;
|
| 111 |
+
|
| 112 |
+
const names = STAGES[getLang()];
|
| 113 |
+
$('#stages').innerHTML = names.map((s, i) => `<div class="st ${i === d.grade ? 'on g' + i : ''}">${i === 4 ? 'Prolif.' : s}</div>`).join('');
|
| 114 |
+
$('#scoreFill').style.width = Math.min(100, Math.max(3, d.score / 4 * 100)) + '%';
|
| 115 |
+
$('#scoreVal').textContent = 'score ' + d.score.toFixed(2);
|
| 116 |
+
if (d.preprocessed) $('#imgPre').src = 'data:image/png;base64,' + d.preprocessed;
|
| 117 |
+
if (d.gradcam) { $('#imgCam').src = 'data:image/png;base64,' + d.gradcam; $('#imgCam').parentElement.style.display = 'block'; }
|
| 118 |
+
else $('#imgCam').parentElement.style.display = 'none';
|
| 119 |
+
$('#why').innerHTML = `<i class="ti ti-bulb"></i><div class="wt"><b>${T('AI พิจารณาอะไร', 'What the AI considered')}:</b> ${TIPS[getLang()][d.grade]} ${T('ภาพด้านบนแสดงบริเวณที่โมเดลให้ความสำคัญ', 'The image above shows where the model focused.')}</div>`;
|
| 120 |
+
show('#result');
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
function backToChoose() {
|
| 124 |
+
['#loading', '#result', '#camPanel'].forEach(s => $(s).style.display = 'none');
|
| 125 |
+
$('#chooser').style.display = 'grid'; $('#upPanel').style.display = 'block';
|
| 126 |
+
$('#tabUp').classList.add('active'); $('#tabCam').classList.remove('active');
|
| 127 |
+
}
|
| 128 |
+
$('#again').onclick = () => { file.value = ''; backToChoose(); };
|
| 129 |
+
$('#send').onclick = () => alert(T('ส่งผลให้จักษุแพทย์ (เชื่อมระบบโรงพยาบาลในเฟสถัดไป)', 'Sent to ophthalmologist (hospital integration in next phase)'));
|
homepage.css
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* RetinaPlus — homepage */
|
| 2 |
+
.hero{padding:70px 0 60px;overflow:hidden;position:relative}
|
| 3 |
+
.hero .container{position:relative;z-index:1}
|
| 4 |
+
.hero-grid{display:grid;grid-template-columns:1.1fr .9fr;gap:48px;align-items:center}
|
| 5 |
+
|
| 6 |
+
/* explainable preview */
|
| 7 |
+
.preview{display:grid;grid-template-columns:1.05fr .95fr;gap:30px;padding:34px;align-items:center}
|
| 8 |
+
.preview .pv-left h3{font-size:23px;font-weight:700;letter-spacing:-.02em;margin:14px 0 10px;line-height:1.25}
|
| 9 |
+
.preview .pv-left p{color:var(--text-2);font-size:15px}
|
| 10 |
+
.pv-stages{display:flex;gap:6px;flex-wrap:wrap;margin-top:18px}
|
| 11 |
+
.pv-stages span{font-size:12px;padding:5px 11px;border-radius:999px;background:var(--surface-2);color:var(--text-3)}
|
| 12 |
+
.pv-stages span.on{background:var(--warn-soft);color:var(--warn);font-weight:600}
|
| 13 |
+
.pv-right{display:grid;grid-template-columns:1fr 1fr;gap:14px}
|
| 14 |
+
.pv-eye{text-align:center}
|
| 15 |
+
.pv-eye b{display:block;font-size:12.5px;color:var(--text-2);margin-top:8px;font-weight:500}
|
| 16 |
+
.eye2{width:100%;aspect-ratio:1;border-radius:18px;background:radial-gradient(circle at 42% 40%,#d98a4a,#9a4a2a 55%,#5a2414);
|
| 17 |
+
box-shadow:inset 0 0 40px rgba(0,0,0,.5);position:relative;overflow:hidden}
|
| 18 |
+
.eye2::after{content:"";position:absolute;left:60%;top:40%;width:22px;height:22px;border-radius:50%;
|
| 19 |
+
background:#f2dca0;box-shadow:0 0 18px rgba(242,220,160,.6)}
|
| 20 |
+
.eye2.heat{background:radial-gradient(circle at 42% 40%,#3a2a5a,#241640)}
|
| 21 |
+
.eye2.heat::before{content:"";position:absolute;left:30%;top:55%;width:46%;height:30%;border-radius:50%;
|
| 22 |
+
background:radial-gradient(circle,rgba(229,75,74,.92),rgba(250,199,117,.5) 55%,transparent 75%)}
|
| 23 |
+
.hero-text h1{font-size:52px;line-height:1.08;letter-spacing:-.03em;font-weight:700;margin:18px 0}
|
| 24 |
+
.hero-text .hl{color:var(--brand)}
|
| 25 |
+
.hero-text p{font-size:18px;color:var(--text-2);max-width:480px}
|
| 26 |
+
.hero-cta{display:flex;gap:12px;margin:30px 0}
|
| 27 |
+
|
| 28 |
+
/* hero — spinning eye (icon-driven) */
|
| 29 |
+
.hero-visual{display:grid;place-items:center;position:relative}
|
| 30 |
+
.eye-stage{position:relative;width:340px;height:340px;display:grid;place-items:center}
|
| 31 |
+
.eye-glow{position:absolute;width:300px;height:300px;border-radius:50%;
|
| 32 |
+
background:radial-gradient(circle at 50% 45%,var(--brand-soft),transparent 68%)}
|
| 33 |
+
.eye-ring{position:absolute;width:312px;height:312px;border-radius:50%;
|
| 34 |
+
border:2px dashed rgba(86,172,246,.45);animation:spin 22s linear infinite}
|
| 35 |
+
.eye-ring2{position:absolute;width:236px;height:236px;border-radius:50%;
|
| 36 |
+
border:1.5px solid rgba(86,172,246,.28);animation:spin 14s linear infinite reverse}
|
| 37 |
+
.eye-img{width:208px;height:auto;position:relative;z-index:2;
|
| 38 |
+
filter:drop-shadow(0 14px 34px rgba(59,155,240,.4));animation:floatY 5.5s ease-in-out infinite}
|
| 39 |
+
.eye-scan{position:absolute;left:50%;top:50%;width:200px;height:3px;transform:translate(-50%,-50%);
|
| 40 |
+
border-radius:2px;background:linear-gradient(90deg,transparent,var(--brand),transparent);
|
| 41 |
+
box-shadow:0 0 16px var(--brand);z-index:3;animation:eyeScan 2.8s var(--ease) infinite}
|
| 42 |
+
@keyframes eyeScan{0%{top:30%}50%{top:70%}100%{top:30%}}
|
| 43 |
+
@keyframes floatY{0%,100%{transform:translateY(0)}50%{transform:translateY(-8px)}}
|
| 44 |
+
|
| 45 |
+
/* hero mini-stat cards */
|
| 46 |
+
.hero-stats{display:flex;gap:12px;margin-top:28px;flex-wrap:wrap}
|
| 47 |
+
.hs{display:flex;align-items:center;gap:11px;background:var(--surface);border:1px solid var(--line);
|
| 48 |
+
border-radius:15px;padding:11px 15px;box-shadow:var(--shadow);transition:.25s var(--ease)}
|
| 49 |
+
.hs:hover{transform:translateY(-3px);border-color:var(--brand)}
|
| 50 |
+
.hs>i{font-size:20px;color:var(--brand);background:var(--brand-soft);width:38px;height:38px;
|
| 51 |
+
border-radius:11px;display:grid;place-items:center;flex-shrink:0}
|
| 52 |
+
.hs b{display:block;font-size:14.5px;font-weight:700;color:var(--text);letter-spacing:-.01em;line-height:1.2}
|
| 53 |
+
.hs span{display:block;font-size:11.5px;color:var(--text-3)}
|
| 54 |
+
|
| 55 |
+
/* severity scale section */
|
| 56 |
+
.sec-sub{text-align:center;color:var(--text-2);font-size:15px;margin:-22px 0 34px}
|
| 57 |
+
.scale-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:14px}
|
| 58 |
+
.scale{padding:24px 18px 22px;position:relative;overflow:hidden;text-align:center}
|
| 59 |
+
.scale::before{content:"";position:absolute;left:0;top:0;width:100%;height:4px;background:var(--c)}
|
| 60 |
+
.scale .sc-no{display:inline-grid;place-items:center;width:42px;height:42px;border-radius:13px;
|
| 61 |
+
font-weight:800;font-size:18px;color:#fff;background:var(--c);margin-bottom:12px;
|
| 62 |
+
box-shadow:0 6px 16px color-mix(in srgb,var(--c) 40%,transparent)}
|
| 63 |
+
.scale h4{font-size:16px;font-weight:700;margin-bottom:6px;letter-spacing:-.01em}
|
| 64 |
+
.scale p{font-size:12.5px;color:var(--text-2);line-height:1.45}
|
| 65 |
+
.s0{--c:#34c759}.s1{--c:#9ccc3f}.s2{--c:#e8910c}.s3{--c:#f0656a}.s4{--c:#e5484d}
|
| 66 |
+
|
| 67 |
+
.section{padding:56px 0}
|
| 68 |
+
.sec-title{font-size:32px;font-weight:700;letter-spacing:-.02em;text-align:center;margin-bottom:36px}
|
| 69 |
+
|
| 70 |
+
.steps{display:grid;grid-template-columns:repeat(3,1fr);gap:18px}
|
| 71 |
+
.step{padding:30px 26px}
|
| 72 |
+
.step-i{width:54px;height:54px;border-radius:15px;background:var(--brand-soft);color:var(--brand-d);
|
| 73 |
+
display:grid;place-items:center;font-size:26px;margin-bottom:16px}
|
| 74 |
+
.step h3{font-size:18px;font-weight:600;margin-bottom:8px}
|
| 75 |
+
.step p{color:var(--text-2);font-size:15px}
|
| 76 |
+
|
| 77 |
+
.feat-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}
|
| 78 |
+
.feat{padding:26px 22px}
|
| 79 |
+
.feat i{font-size:28px;color:var(--brand);margin-bottom:12px;display:block}
|
| 80 |
+
.feat h3{font-size:16.5px;font-weight:600;margin-bottom:6px}
|
| 81 |
+
.feat p{font-size:14px;color:var(--text-2)}
|
| 82 |
+
|
| 83 |
+
.cta-band{margin:30px 24px 0;padding:56px 24px;text-align:center;
|
| 84 |
+
background:linear-gradient(135deg,#2487e0,#4aa6f5);border-radius:var(--r-xl);color:#fff}
|
| 85 |
+
.cta-band h2{font-size:32px;font-weight:700;letter-spacing:-.02em}
|
| 86 |
+
.cta-band p{opacity:.92;margin:10px 0 24px;font-size:16px}
|
| 87 |
+
.cta-band .btn-primary{background:#fff;color:var(--brand-d);box-shadow:0 8px 24px rgba(0,0,0,.18)}
|
| 88 |
+
.cta-band .btn-primary:hover{background:#f3f3f3}
|
| 89 |
+
|
| 90 |
+
@media(max-width:880px){
|
| 91 |
+
.hero-grid,.steps,.preview{grid-template-columns:1fr}
|
| 92 |
+
.hero-text h1{font-size:38px}.hero-visual{order:-1}
|
| 93 |
+
.eye-stage{width:280px;height:280px}.eye-img{width:178px}
|
| 94 |
+
.feat-grid{grid-template-columns:1fr 1fr}
|
| 95 |
+
.scale-grid{grid-template-columns:repeat(2,1fr)}
|
| 96 |
+
.preview{gap:22px}.preview .pv-right{max-width:360px}
|
| 97 |
+
}
|
| 98 |
+
@media(max-width:560px){
|
| 99 |
+
.scale-grid{grid-template-columns:1fr}
|
| 100 |
+
.hero-stats{gap:10px}.hs{flex:1;min-width:140px}
|
| 101 |
+
}
|
homepage.html
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="th">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>RetinaPlus</title>
|
| 7 |
+
<link rel="icon" href="icon.png">
|
| 8 |
+
<link rel="stylesheet" href="shared.css">
|
| 9 |
+
<link rel="stylesheet" href="homepage.css">
|
| 10 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@3.3.0/dist/tabler-icons.min.css">
|
| 11 |
+
</head>
|
| 12 |
+
<body>
|
| 13 |
+
<nav class="nav">
|
| 14 |
+
<a class="brand" href="/"><img src="icon.png" class="logo-img" alt="RetinaPlus"><span class="brand-name">Retina<b>Plus</b></span></a>
|
| 15 |
+
<div class="nav-links">
|
| 16 |
+
<a href="/" class="active" data-th="หน้าแรก" data-en="Home">หน้าแรก</a>
|
| 17 |
+
<a href="/detect" data-th="ตรวจ" data-en="Screen">ตรวจ</a>
|
| 18 |
+
<a href="/dashboard" data-th="แดชบอร์ด" data-en="Dashboard">แดชบอร์ด</a>
|
| 19 |
+
<div class="nav-tools">
|
| 20 |
+
<button class="tool-btn" data-tool="theme" onclick="toggleTheme()" aria-label="theme"><i class="ti ti-moon"></i></button>
|
| 21 |
+
<button class="tool-btn lang" data-tool="lang" onclick="toggleLang()">EN</button>
|
| 22 |
+
</div>
|
| 23 |
+
<a href="/detect" class="btn btn-primary" style="padding:9px 18px" data-th="เริ่มตรวจ" data-en="Start">เริ่มตรวจ</a>
|
| 24 |
+
</div>
|
| 25 |
+
</nav>
|
| 26 |
+
|
| 27 |
+
<header class="hero">
|
| 28 |
+
<div class="dots"></div>
|
| 29 |
+
<span class="glow a" style="width:420px;height:420px;top:-100px;right:-80px"></span>
|
| 30 |
+
<span class="glow b" style="width:340px;height:340px;bottom:-120px;left:-90px"></span>
|
| 31 |
+
<div class="container hero-grid">
|
| 32 |
+
<div class="hero-text">
|
| 33 |
+
<span class="pill pill-ok reveal"><i class="ti ti-eye-check"></i>
|
| 34 |
+
<span data-th="คัดกรองเบาหวานขึ้นจอตาด้วย AI" data-en="AI retinopathy screening">คัดกรองเบาหวานขึ้นจอตาด้วย AI</span></span>
|
| 35 |
+
<h1 class="reveal d1">
|
| 36 |
+
<span data-th="คัดกรอง" data-en="Screen for ">คัดกรอง</span><span class="hl" data-th="เบาหวานขึ้นจอตา" data-en="diabetic retinopathy">เบาหวานขึ้นจอตา</span>
|
| 37 |
+
<span data-th="จากภาพถ่ายจอตา" data-en="from fundus images">จากภาพถ่ายจอตา</span>
|
| 38 |
+
</h1>
|
| 39 |
+
<p class="reveal d2" data-th="อัปโหลดหรือถ่ายภาพจอตา ระบบประเมินระดับความรุนแรงและความเสี่ยง พร้อมไฮไลต์บริเวณที่ผิดปกติให้แพทย์ตรวจสอบ"
|
| 40 |
+
data-en="Upload or capture a fundus image. The system estimates the severity level and risk, and highlights abnormal regions for the doctor to review.">อัปโหลดหรือถ่ายภาพจอตา ระบบประเมินระดับความรุนแรงและความเสี่ยง พร้อมไฮไลต์บริเวณที่ผิดปกติให้แพทย์ตรวจสอบ</p>
|
| 41 |
+
<div class="hero-cta reveal d3">
|
| 42 |
+
<a href="/detect" class="btn btn-primary"><i class="ti ti-camera"></i> <span data-th="เริ่มตรวจเลย" data-en="Start screening">เริ่มตรวจเลย</span></a>
|
| 43 |
+
<a href="#how" class="btn btn-ghost" data-th="วิธีใช้งาน" data-en="How it works">วิธีใช้งาน</a>
|
| 44 |
+
</div>
|
| 45 |
+
<div class="hero-stats reveal d4">
|
| 46 |
+
<div class="hs"><i class="ti ti-stack-2"></i><div><b data-th="5 ระดับ" data-en="5 levels">5 ระดับ</b><span data-th="ความรุนแรง" data-en="of severity">ความรุนแรง</span></div></div>
|
| 47 |
+
<div class="hs"><i class="ti ti-bolt"></i><div><b data-th="ไม่กี่วินาที" data-en="Seconds">ไม่กี่วินาที</b><span data-th="รู้ผลทันที" data-en="to results">รู้ผลทันที</span></div></div>
|
| 48 |
+
<div class="hs"><i class="ti ti-flare"></i><div><b>Grad-CAM</b><span data-th="อธิบายผลได้" data-en="explainable">อธิบายผลได้</span></div></div>
|
| 49 |
+
</div>
|
| 50 |
+
</div>
|
| 51 |
+
<div class="hero-visual reveal d2">
|
| 52 |
+
<div class="eye-stage">
|
| 53 |
+
<span class="eye-ring"></span>
|
| 54 |
+
<span class="eye-ring2"></span>
|
| 55 |
+
<span class="eye-glow"></span>
|
| 56 |
+
<img src="icon.png" class="eye-img" alt="">
|
| 57 |
+
<span class="eye-scan"></span>
|
| 58 |
+
</div>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
</header>
|
| 62 |
+
|
| 63 |
+
<section class="section">
|
| 64 |
+
<div class="container feat-grid">
|
| 65 |
+
<div class="card feat hov reveal"><i class="ti ti-bolt"></i>
|
| 66 |
+
<h3 data-th="ประมวลผลไว" data-en="Fast">ประมวลผลไว</h3>
|
| 67 |
+
<p data-th="รู้ผลภายในไม่กี่วินาที" data-en="Results in a few seconds">รู้ผลภายในไม่กี่วินาที</p></div>
|
| 68 |
+
<div class="card feat hov reveal d1"><i class="ti ti-shield-lock"></i>
|
| 69 |
+
<h3 data-th="ปลอดภัย" data-en="Secure">ปลอดภัย</h3>
|
| 70 |
+
<p data-th="ไม่บุกรุกร่างกาย" data-en="Processed on-device, data stays private">ประมวลผลในเครื่อง ข้อมูลไม่รั่วไหล</p></div>
|
| 71 |
+
<div class="card feat hov reveal d2"><i class="ti ti-hand-finger"></i>
|
| 72 |
+
<h3 data-th="ใช้งานง่าย" data-en="Easy to use">ใช้งานง่าย</h3>
|
| 73 |
+
<p data-th="ถ่ายหรืออัปโหลดภาพ รู้ผลทันที" data-en="Capture or upload, get instant results">ถ่ายหรืออัปโหลดภาพ รู้ผลทันที</p></div>
|
| 74 |
+
<div class="card feat hov reveal d3"><i class="ti ti-target-arrow"></i>
|
| 75 |
+
<h3 data-th="ความแม่นยำสูง" data-en="High accuracy">ความแม่นยำสูง</h3>
|
| 76 |
+
<p data-th="โมเดล AI ประเมินระดับได้แม่นยำ" data-en="Accurate AI severity grading">โมเดล AI ประเมินระดับได้แม่นยำ</p></div>
|
| 77 |
+
</div>
|
| 78 |
+
</section>
|
| 79 |
+
|
| 80 |
+
<section class="section scale-sec">
|
| 81 |
+
<div class="container">
|
| 82 |
+
<h2 class="sec-title reveal" data-th="ประเมินได้ 5 ระดับความรุนแรง" data-en="Grades all 5 severity levels">ประเมินได้ 5 ระดับความรุนแรง</h2>
|
| 83 |
+
<p class="sec-sub reveal" data-th="ระบบจัดระดับตามมาตรฐานสากล ตั้งแต่ปกติจนถึงระยะลุกลาม"
|
| 84 |
+
data-en="Graded on the international scale, from normal to proliferative">ระบบจัดระดับตามมาตรฐานสากล ตั้งแต่ปกติจนถึงระยะลุกลาม</p>
|
| 85 |
+
<div class="scale-grid">
|
| 86 |
+
<div class="card scale s0 hov reveal"><span class="sc-no">0</span>
|
| 87 |
+
<h4>No DR</h4><p data-th="ไม่พบเบาหวานขึ้นจอตา" data-en="No retinopathy">ไม่พบความผิดปกติ</p></div>
|
| 88 |
+
<div class="card scale s1 hov reveal d1"><span class="sc-no">1</span>
|
| 89 |
+
<h4 data-th="เล็กน้อย" data-en="Mild">เล็กน้อย</h4><p data-th="พบ microaneurysm เริ่มต้น" data-en="Early microaneurysms">พบจุดเลือดเล็กเริ่มต้น</p></div>
|
| 90 |
+
<div class="card scale s2 hov reveal d2"><span class="sc-no">2</span>
|
| 91 |
+
<h4 data-th="ปานกลาง" data-en="Moderate">ปานกลาง</h4><p data-th="จุดเลือดออก / hard exudate" data-en="Hemorrhages / exudates">จุดเลือดออก/คราบไขมัน</p></div>
|
| 92 |
+
<div class="card scale s3 hov reveal d3"><span class="sc-no">3</span>
|
| 93 |
+
<h4 data-th="รุนแรง" data-en="Severe">รุนแรง</h4><p data-th="ความผิดปกติชัดเจน ควรพบแพทย์" data-en="Marked abnormalities">ผิดปกติชัด ควรพบแพทย์</p></div>
|
| 94 |
+
<div class="card scale s4 hov reveal d4"><span class="sc-no">4</span>
|
| 95 |
+
<h4 data-th="ลุกลาม" data-en="Proliferative">ลุกลาม</h4><p data-th="เส้นเลือดงอกผิดปกติ เร่งด่วน" data-en="Neovascularization">เส้นเลือดงอกผิดปกติ</p></div>
|
| 96 |
+
</div>
|
| 97 |
+
</div>
|
| 98 |
+
</section>
|
| 99 |
+
|
| 100 |
+
<section class="section" id="how">
|
| 101 |
+
<div class="container">
|
| 102 |
+
<h2 class="sec-title reveal" data-th="ใช้งาน 3 ขั้นตอน" data-en="Three simple steps">ใช้งาน 3 ขั้นตอน</h2>
|
| 103 |
+
<div class="steps">
|
| 104 |
+
<div class="card step hov reveal"><span class="step-i"><i class="ti ti-camera"></i></span>
|
| 105 |
+
<h3 data-th="1 · ถ่ายหรืออัปโหลด" data-en="1 · Capture or upload">1 · ถ่ายหรืออัปโหลด</h3>
|
| 106 |
+
<p data-th="ถ่ายภาพจอตาสด หรืออัปโหลดไฟล์ภาพ" data-en="Capture live or upload a fundus image">ถ่ายภาพจอตาสด หรืออัปโหลดไฟล์ภาพ</p></div>
|
| 107 |
+
<div class="card step hov reveal d1"><span class="step-i"><i class="ti ti-brain"></i></span>
|
| 108 |
+
<h3 data-th="2 · AI วิเคราะห์" data-en="2 · AI analyzes">2 · AI วิเคราะห์</h3>
|
| 109 |
+
<p data-th="ประเมินระดับ + ไฮไลต์บริเวณผิดปกติ" data-en="Grades severity + highlights regions">ประเมินระดับ + ไฮไลต์บริเวณผิดปกติ</p></div>
|
| 110 |
+
<div class="card step hov reveal d2"><span class="step-i"><i class="ti ti-stethoscope"></i></span>
|
| 111 |
+
<h3 data-th="3 · ส่งต่อแพทย์" data-en="3 · Send to doctor">3 · ส่งต่อแพทย์</h3>
|
| 112 |
+
<p data-th="สรุปผล + ภาพวิเคราะห์ ให้แพทย์ตรวจสอบ" data-en="Summary + analysis for doctor review">สรุปผล + ภาพวิเคราะห์ ให้แพทย์ตรวจสอบ</p></div>
|
| 113 |
+
</div>
|
| 114 |
+
</div>
|
| 115 |
+
</section>
|
| 116 |
+
|
| 117 |
+
<section class="section">
|
| 118 |
+
<div class="container">
|
| 119 |
+
<h2 class="sec-title reveal" data-th="ผลที่อธิบายได้" data-en="Explainable results">ผลที่อธิบายได้</h2>
|
| 120 |
+
<div class="preview card reveal d1">
|
| 121 |
+
<div class="pv-left">
|
| 122 |
+
<span class="pill pill-bad"><i class="ti ti-alert-triangle"></i>
|
| 123 |
+
<span data-th="ควรพบจักษุแพทย์" data-en="Refer to doctor">ควรพบจักษุแพทย์</span></span>
|
| 124 |
+
<h3 data-th="ไม่ใช่แค่บอกผล — แต่ชี้ให้เห็นว่า AI ดูตรงไหน"
|
| 125 |
+
data-en="Not just an answer — it shows where the AI looked">ไม่ใช่แค่บอกผล — แต่ชี้ให้เห็นว่า AI ดูตรงไหน</h3>
|
| 126 |
+
<p data-th="ระบบไฮไลต์บริเวณที่ผิดปกติ ให้จักษุแพทย์ตรวจสอบได้ พร้อมระดับความรุนแรงและความเสี่ยง"
|
| 127 |
+
data-en="It highlights abnormal regions for the doctor to verify, with severity level and risk.">ระบบไฮไลต์บริเวณที่ผิดปกติ ให้จักษุแพทย์ตรวจสอบได้ พร้อมระดับความรุนแรงและความเสี่ยง</p>
|
| 128 |
+
<div class="pv-stages">
|
| 129 |
+
<span>No DR</span><span>Mild</span><span class="on">Moderate</span><span>Severe</span><span>Prolif.</span>
|
| 130 |
+
</div>
|
| 131 |
+
</div>
|
| 132 |
+
<div class="pv-right">
|
| 133 |
+
<div class="pv-eye"><div class="eye2"></div><b data-th="ภาพจอตา" data-en="Fundus">ภาพจอตา</b></div>
|
| 134 |
+
<div class="pv-eye"><div class="eye2 heat"></div><b>Grad-CAM</b></div>
|
| 135 |
+
</div>
|
| 136 |
+
</div>
|
| 137 |
+
</div>
|
| 138 |
+
</section>
|
| 139 |
+
|
| 140 |
+
<section class="cta-band">
|
| 141 |
+
<div class="container">
|
| 142 |
+
<h2 class="reveal" data-th="พร้อมคัดกรองแล้วหรือยัง?" data-en="Ready to screen?">พร้อมคัดกรองแล้วหรือยัง?</h2>
|
| 143 |
+
<p class="reveal d1" data-th="เครื่องมือคัดกรองเบื้องต้น ผลควรได้รับการยืนยันโดยจักษุแพทย์"
|
| 144 |
+
data-en="A screening aid — results should be confirmed by an ophthalmologist.">เครื่องมือคัดกรองเบื้องต้น ผลควรได้รับการยืนยันโดยจักษุแพทย์</p>
|
| 145 |
+
<a href="/detect" class="btn btn-primary reveal d2"><i class="ti ti-camera"></i> <span data-th="เริ่มตรวจ" data-en="Start">เริ่มตรวจ</span></a>
|
| 146 |
+
</div>
|
| 147 |
+
</section>
|
| 148 |
+
|
| 149 |
+
<footer class="footer">
|
| 150 |
+
<span class="footer-brand"><img src="icon.png" class="logo-img" alt="RetinaPlus">Retina<b>Plus</b></span>
|
| 151 |
+
<span data-th="เครื่องมือช่วยคัดกรองเบาหวานขึ้นจอตา · ไม่ใช่การวินิจฉัย ผลควรได้รับการยืนยันโดยจักษุแพทย์"
|
| 152 |
+
data-en="A diabetic retinopathy screening aid · not a diagnosis — confirm with an ophthalmologist">เครื่องมือช่วยคัดกรองเบาหวานขึ้นจอตา · ไม่ใช่การวินิจฉัย ผลควรได้รับการยืนยันโดยจักษุแพทย์</span>
|
| 153 |
+
<span style="font-size:12px;opacity:.7">© 2025 RetinaPlus · <span data-th="พัฒนาโดย Nathakorn" data-en="Developed by Nathakorn">พัฒนาโดย Nathakorn</span></span>
|
| 154 |
+
</footer>
|
| 155 |
+
<script src="shared.js"></script>
|
| 156 |
+
<script src="homepage.js"></script>
|
| 157 |
+
</body>
|
| 158 |
+
</html>
|
homepage.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// reveal on scroll
|
| 2 |
+
const io = new IntersectionObserver((entries) => {
|
| 3 |
+
entries.forEach(e => { if (e.isIntersecting) { e.target.style.animationPlayState = 'running'; io.unobserve(e.target); } });
|
| 4 |
+
}, { threshold: 0.12 });
|
| 5 |
+
document.querySelectorAll('.reveal').forEach(el => {
|
| 6 |
+
if (el.getBoundingClientRect().top > window.innerHeight) {
|
| 7 |
+
el.style.animationPlayState = 'paused';
|
| 8 |
+
io.observe(el);
|
| 9 |
+
}
|
| 10 |
+
});
|
icon.png
ADDED
|
|
Git LFS Details
|
models/README.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
วาง best.pt ที่นี่ (v4 + v3)
|
models/v3_best.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2e1d277933387c6c41e6171ce3fd28683ba1b26001d4fca4d407de2e16415a51
|
| 3 |
+
size 70912867
|
models/v4_best.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e60c419500d7d36b07ca5dde4044802e157564cc449f128a2564f26a68eecb6b
|
| 3 |
+
size 70912867
|
requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
flask==3.0.3
|
| 2 |
+
flask-cors==4.0.1
|
| 3 |
+
gunicorn==21.2.0
|
| 4 |
+
numpy==1.26.4
|
| 5 |
+
opencv-python-headless==4.10.0.84
|
| 6 |
+
torch==2.2.2
|
| 7 |
+
timm==1.0.7
|
| 8 |
+
grad-cam==1.5.0
|
shared.css
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* RetinaPlus — shared design system (iOS-modern, clean medical) */
|
| 2 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
| 3 |
+
|
| 4 |
+
:root{
|
| 5 |
+
--bg:#F4F7FB;
|
| 6 |
+
--surface:#FFFFFF;
|
| 7 |
+
--surface-2:#F0F4F9;
|
| 8 |
+
--text:#16202E;
|
| 9 |
+
--text-2:#5A6776;
|
| 10 |
+
--text-3:#93A0AE;
|
| 11 |
+
--brand:#3B9BF0; /* light blue — calm medical */
|
| 12 |
+
--brand-d:#1F77D6;
|
| 13 |
+
--brand-soft:#E7F2FD;
|
| 14 |
+
--danger:#E5484D;
|
| 15 |
+
--danger-soft:#FCE9E9;
|
| 16 |
+
--warn:#E8910C;
|
| 17 |
+
--warn-soft:#FCF0DB;
|
| 18 |
+
--line:#E6ECF3;
|
| 19 |
+
--shadow:0 4px 24px rgba(20,40,70,.06);
|
| 20 |
+
--shadow-lg:0 12px 40px rgba(20,40,70,.10);
|
| 21 |
+
--nav-bg:rgba(255,255,255,.72);
|
| 22 |
+
--glow-a:rgba(59,155,240,.16); --glow-b:rgba(120,200,255,.13);
|
| 23 |
+
--r:14px; --r-lg:22px; --r-xl:30px;
|
| 24 |
+
--ease:cubic-bezier(.22,.61,.36,1);
|
| 25 |
+
}
|
| 26 |
+
[data-theme="dark"]{
|
| 27 |
+
--bg:#0B121B; --surface:#161F2B; --surface-2:#1E2A38;
|
| 28 |
+
--text:#EAF0F7; --text-2:#A3B1C0; --text-3:#6E7E90;
|
| 29 |
+
--brand:#56ACF6; --brand-d:#86C2F9; --brand-soft:#163049;
|
| 30 |
+
--danger:#F0656A; --danger-soft:#3A1E20; --warn:#F0A93A; --warn-soft:#3A2C12;
|
| 31 |
+
--line:#27333F; --shadow:0 4px 24px rgba(0,0,0,.35); --shadow-lg:0 12px 40px rgba(0,0,0,.5);
|
| 32 |
+
--nav-bg:rgba(13,20,29,.82);
|
| 33 |
+
--glow-a:rgba(60,130,210,.20); --glow-b:rgba(40,90,150,.16);
|
| 34 |
+
}
|
| 35 |
+
html{transition:background .3s var(--ease)}
|
| 36 |
+
*{box-sizing:border-box;margin:0;padding:0}
|
| 37 |
+
html{scroll-behavior:smooth}
|
| 38 |
+
body{
|
| 39 |
+
font-family:'Inter',-apple-system,BlinkMacSystemFont,sans-serif;
|
| 40 |
+
background:var(--bg);color:var(--text);
|
| 41 |
+
-webkit-font-smoothing:antialiased;line-height:1.6;
|
| 42 |
+
}
|
| 43 |
+
a{color:inherit;text-decoration:none}
|
| 44 |
+
img{max-width:100%;display:block}
|
| 45 |
+
|
| 46 |
+
/* nav */
|
| 47 |
+
.nav{
|
| 48 |
+
position:sticky;top:0;z-index:50;
|
| 49 |
+
display:flex;align-items:center;justify-content:space-between;
|
| 50 |
+
padding:10px 28px;
|
| 51 |
+
min-height:72px;
|
| 52 |
+
background:var(--nav-bg);backdrop-filter:saturate(180%) blur(20px);
|
| 53 |
+
-webkit-backdrop-filter:saturate(180%) blur(20px);
|
| 54 |
+
border-bottom:1px solid var(--line);
|
| 55 |
+
}
|
| 56 |
+
.brand{display:flex;align-items:center;gap:11px;font-weight:800;font-size:22px;letter-spacing:-.025em;color:var(--text)}
|
| 57 |
+
.brand-name b{color:var(--brand);font-weight:800}
|
| 58 |
+
.nav-links{display:flex;gap:6px;align-items:center}
|
| 59 |
+
.nav-links a{padding:8px 16px;border-radius:11px;font-size:14.5px;font-weight:500;color:var(--text-2);
|
| 60 |
+
transition:.2s var(--ease)}
|
| 61 |
+
.nav-links a:hover{background:var(--surface-2);color:var(--text)}
|
| 62 |
+
.nav-links a.active{color:var(--brand);background:var(--brand-soft)}
|
| 63 |
+
.nav-tools{display:flex;gap:6px;align-items:center;margin-left:4px}
|
| 64 |
+
.tool-btn{width:38px;height:38px;border-radius:11px;border:1px solid var(--line);background:var(--surface);
|
| 65 |
+
color:var(--text-2);cursor:pointer;display:grid;place-items:center;font-size:18px;transition:.2s var(--ease);font-family:inherit;font-weight:600}
|
| 66 |
+
.tool-btn:hover{background:var(--surface-2);color:var(--text)}
|
| 67 |
+
.tool-btn.lang{width:auto;padding:0 12px;font-size:13px}
|
| 68 |
+
.logo-img{height:46px;width:46px;object-fit:contain;display:block}
|
| 69 |
+
|
| 70 |
+
/* decorative glow blobs (modern, soft) */
|
| 71 |
+
.glow{position:absolute;border-radius:50%;filter:blur(70px);pointer-events:none;z-index:0}
|
| 72 |
+
.glow.a{background:var(--glow-a)}.glow.b{background:var(--glow-b)}
|
| 73 |
+
|
| 74 |
+
/* dotted texture */
|
| 75 |
+
.dots{position:absolute;inset:0;z-index:0;pointer-events:none;opacity:.5;
|
| 76 |
+
background-image:radial-gradient(var(--line) 1px,transparent 1px);background-size:26px 26px;
|
| 77 |
+
-webkit-mask-image:radial-gradient(ellipse 70% 60% at 50% 30%,#000,transparent 75%);
|
| 78 |
+
mask-image:radial-gradient(ellipse 70% 60% at 50% 30%,#000,transparent 75%)}
|
| 79 |
+
|
| 80 |
+
/* card hover lift */
|
| 81 |
+
.card.hov{transition:.28s var(--ease)}
|
| 82 |
+
.card.hov:hover{transform:translateY(-5px);border-color:var(--brand);box-shadow:var(--shadow-lg)}
|
| 83 |
+
|
| 84 |
+
/* footer with logo */
|
| 85 |
+
.footer{text-align:center;color:var(--text-3);font-size:13px;padding:48px 24px 36px;
|
| 86 |
+
display:flex;flex-direction:column;align-items:center;gap:12px}
|
| 87 |
+
.footer-brand{display:flex;align-items:center;gap:10px;font-weight:800;font-size:19px;letter-spacing:-.02em;color:var(--text)}
|
| 88 |
+
.footer-brand .logo-img{height:42px;width:42px}
|
| 89 |
+
.footer-brand b{color:var(--brand)}
|
| 90 |
+
|
| 91 |
+
/* buttons */
|
| 92 |
+
.btn{display:inline-flex;align-items:center;gap:8px;justify-content:center;
|
| 93 |
+
padding:13px 26px;border-radius:14px;font-weight:600;font-size:15px;cursor:pointer;
|
| 94 |
+
border:none;transition:.25s var(--ease);font-family:inherit}
|
| 95 |
+
.btn-primary{background:var(--brand);color:#fff;box-shadow:0 6px 18px rgba(59,155,240,.30)}
|
| 96 |
+
.btn-primary:hover{background:var(--brand-d);transform:translateY(-2px);box-shadow:0 10px 26px rgba(59,155,240,.38)}
|
| 97 |
+
.btn-ghost{background:var(--surface);color:var(--text);border:1px solid var(--line)}
|
| 98 |
+
.btn-ghost:hover{background:var(--surface-2);transform:translateY(-2px)}
|
| 99 |
+
|
| 100 |
+
/* cards */
|
| 101 |
+
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);
|
| 102 |
+
box-shadow:var(--shadow)}
|
| 103 |
+
.container{max-width:1080px;margin:0 auto;padding:0 24px}
|
| 104 |
+
|
| 105 |
+
/* pills */
|
| 106 |
+
.pill{display:inline-flex;align-items:center;gap:6px;padding:6px 14px;border-radius:999px;
|
| 107 |
+
font-size:13px;font-weight:600}
|
| 108 |
+
.pill-ok{background:var(--brand-soft);color:var(--brand-d)}
|
| 109 |
+
.pill-bad{background:var(--danger-soft);color:var(--danger)}
|
| 110 |
+
.pill-warn{background:var(--warn-soft);color:var(--warn)}
|
| 111 |
+
|
| 112 |
+
/* animations */
|
| 113 |
+
@keyframes fadeUp{from{opacity:0;transform:translateY(24px)}to{opacity:1;transform:none}}
|
| 114 |
+
@keyframes pop{from{opacity:0;transform:scale(.94)}to{opacity:1;transform:none}}
|
| 115 |
+
@keyframes spin{to{transform:rotate(360deg)}}
|
| 116 |
+
.reveal{opacity:0;animation:fadeUp .7s var(--ease) forwards}
|
| 117 |
+
.reveal.d1{animation-delay:.08s}.reveal.d2{animation-delay:.16s}.reveal.d3{animation-delay:.24s}
|
| 118 |
+
.reveal.d4{animation-delay:.32s}
|
| 119 |
+
|
| 120 |
+
@media(max-width:680px){
|
| 121 |
+
.nav{padding:10px 14px;min-height:60px}
|
| 122 |
+
.nav-links{gap:3px}
|
| 123 |
+
.nav-links a:not(.btn){padding:6px 8px;font-size:12.5px}
|
| 124 |
+
.logo-img{height:40px;width:40px}
|
| 125 |
+
.brand{font-size:18px;gap:9px}
|
| 126 |
+
.tool-btn{width:34px;height:34px;font-size:16px}
|
| 127 |
+
.tool-btn.lang{padding:0 9px;font-size:12px}
|
| 128 |
+
}
|
| 129 |
+
@media(max-width:520px){
|
| 130 |
+
.nav-links a.btn-primary{display:none}
|
| 131 |
+
.nav-links a:not(.btn){padding:5px 6px;font-size:12px}
|
| 132 |
+
.brand .logo-img{height:36px;width:36px}
|
| 133 |
+
.brand-name{display:none}
|
| 134 |
+
}
|
shared.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// RetinaPlus — theme + language (i18n) engine, loaded on every page
|
| 2 |
+
(function () {
|
| 3 |
+
const root = document.documentElement;
|
| 4 |
+
|
| 5 |
+
// ---- theme ----
|
| 6 |
+
const theme = localStorage.getItem('rp-theme') || 'light';
|
| 7 |
+
root.setAttribute('data-theme', theme);
|
| 8 |
+
window.toggleTheme = function () {
|
| 9 |
+
const t = root.getAttribute('data-theme') === 'dark' ? 'light' : 'dark';
|
| 10 |
+
root.setAttribute('data-theme', t);
|
| 11 |
+
localStorage.setItem('rp-theme', t);
|
| 12 |
+
paintTools();
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
// ---- language ----
|
| 16 |
+
let lang = localStorage.getItem('rp-lang') || 'th'; // default Thai
|
| 17 |
+
function applyLang() {
|
| 18 |
+
document.documentElement.lang = lang;
|
| 19 |
+
document.querySelectorAll('[data-th]').forEach(el => {
|
| 20 |
+
const v = el.getAttribute('data-' + lang);
|
| 21 |
+
if (v != null) {
|
| 22 |
+
if (el.hasAttribute('data-attr')) el.setAttribute(el.getAttribute('data-attr'), v);
|
| 23 |
+
else el.textContent = v;
|
| 24 |
+
}
|
| 25 |
+
});
|
| 26 |
+
document.title = (document.querySelector('[data-title-' + lang + ']')?.getAttribute('data-title-' + lang)) || document.title;
|
| 27 |
+
}
|
| 28 |
+
window.toggleLang = function () {
|
| 29 |
+
lang = lang === 'th' ? 'en' : 'th';
|
| 30 |
+
localStorage.setItem('rp-lang', lang);
|
| 31 |
+
applyLang(); paintTools();
|
| 32 |
+
};
|
| 33 |
+
window.getLang = () => lang;
|
| 34 |
+
|
| 35 |
+
// ---- tool buttons label ----
|
| 36 |
+
function paintTools() {
|
| 37 |
+
const t = root.getAttribute('data-theme');
|
| 38 |
+
document.querySelectorAll('[data-tool="theme"] i').forEach(i =>
|
| 39 |
+
i.className = 'ti ' + (t === 'dark' ? 'ti-sun' : 'ti-moon'));
|
| 40 |
+
document.querySelectorAll('[data-tool="lang"]').forEach(b =>
|
| 41 |
+
b.textContent = lang === 'th' ? 'EN' : 'ไทย');
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
document.addEventListener('DOMContentLoaded', function () { applyLang(); paintTools(); });
|
| 45 |
+
})();
|