797 lines
29 KiB
HTML
797 lines
29 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="vi">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Cloud Removal Training - Deep Learning</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
background-attachment: fixed;
|
|
min-height: 100vh;
|
|
padding: 20px;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
background: rgba(255, 255, 255, 0.95);
|
|
backdrop-filter: blur(20px);
|
|
border-radius: 24px;
|
|
box-shadow: 0 25px 80px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.1);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.header {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
padding: 40px 30px;
|
|
text-align: center;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.header::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: -50%;
|
|
right: -50%;
|
|
width: 200%;
|
|
height: 200%;
|
|
background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
|
|
animation: headerGlow 8s ease-in-out infinite;
|
|
}
|
|
|
|
@keyframes headerGlow {
|
|
0%, 100% { transform: translate(0, 0); }
|
|
50% { transform: translate(-20%, -20%); }
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 2.8em;
|
|
margin-bottom: 12px;
|
|
font-weight: 700;
|
|
position: relative;
|
|
z-index: 1;
|
|
text-shadow: 0 2px 20px rgba(0,0,0,0.2);
|
|
}
|
|
|
|
.header p {
|
|
font-size: 1.15em;
|
|
opacity: 0.95;
|
|
position: relative;
|
|
z-index: 1;
|
|
font-weight: 400;
|
|
}
|
|
|
|
.nav {
|
|
background: rgba(255,255,255,0.8);
|
|
backdrop-filter: blur(10px);
|
|
padding: 18px 30px;
|
|
border-bottom: 1px solid rgba(0,0,0,0.08);
|
|
box-shadow: 0 2px 10px rgba(0,0,0,0.03);
|
|
display: flex;
|
|
gap: 12px;
|
|
flex-wrap: wrap;
|
|
justify-content: center;
|
|
}
|
|
|
|
.nav a {
|
|
padding: 12px 24px;
|
|
color: white;
|
|
text-decoration: none;
|
|
border-radius: 12px;
|
|
font-weight: 600;
|
|
transition: all 0.3s;
|
|
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
|
|
}
|
|
|
|
.nav a:nth-child(1) { background: linear-gradient(135deg, #667eea, #764ba2); }
|
|
.nav a:nth-child(2) { background: linear-gradient(135deg, #f093fb, #f5576c); }
|
|
.nav a:nth-child(3) { background: linear-gradient(135deg, #4facfe, #00f2fe); }
|
|
.nav a:nth-child(4) { background: linear-gradient(135deg, #43e97b, #38f9d7); }
|
|
|
|
.nav a:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
|
|
}
|
|
|
|
.content {
|
|
padding: 30px;
|
|
}
|
|
|
|
.section {
|
|
margin-bottom: 30px;
|
|
padding: 28px;
|
|
background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
|
|
border-radius: 16px;
|
|
border: 1px solid rgba(0,0,0,0.06);
|
|
box-shadow: 0 4px 20px rgba(0,0,0,0.04);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.section:hover {
|
|
box-shadow: 0 8px 30px rgba(102, 126, 234, 0.12);
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.section-title {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
background-clip: text;
|
|
font-size: 1.6em;
|
|
font-weight: 700;
|
|
margin-bottom: 20px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
.card {
|
|
background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
|
|
border-radius: 12px;
|
|
padding: 24px;
|
|
margin-bottom: 20px;
|
|
border: 1px solid rgba(0,0,0,0.05);
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.04);
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
position: relative;
|
|
}
|
|
|
|
label {
|
|
display: block;
|
|
font-weight: 600;
|
|
margin-bottom: 8px;
|
|
color: #374151;
|
|
font-size: 0.95em;
|
|
letter-spacing: 0.01em;
|
|
}
|
|
|
|
input[type="text"],
|
|
input[type="number"],
|
|
select {
|
|
width: 100%;
|
|
padding: 12px 16px;
|
|
border: 2px solid #e5e7eb;
|
|
border-radius: 12px;
|
|
font-size: 1em;
|
|
transition: all 0.3s ease;
|
|
background: white;
|
|
font-family: inherit;
|
|
}
|
|
|
|
input[type="text"]:hover,
|
|
input[type="number"]:hover,
|
|
select:hover {
|
|
border-color: #d1d5db;
|
|
}
|
|
|
|
input[type="text"]:focus,
|
|
input[type="number"]:focus,
|
|
select:focus {
|
|
outline: none;
|
|
border-color: #667eea;
|
|
box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.checkbox-group {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
gap: 12px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
input[type="checkbox"] {
|
|
width: 20px;
|
|
height: 20px;
|
|
cursor: pointer;
|
|
margin-top: 2px;
|
|
}
|
|
|
|
.btn {
|
|
padding: 14px 32px;
|
|
border: none;
|
|
border-radius: 12px;
|
|
font-size: 1em;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
margin-right: 10px;
|
|
position: relative;
|
|
overflow: hidden;
|
|
font-family: inherit;
|
|
}
|
|
|
|
.btn::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
width: 0;
|
|
height: 0;
|
|
border-radius: 50%;
|
|
background: rgba(255,255,255,0.3);
|
|
transform: translate(-50%, -50%);
|
|
transition: width 0.6s, height 0.6s;
|
|
}
|
|
|
|
.btn:hover::before {
|
|
width: 300px;
|
|
height: 300px;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
transform: translateY(-3px);
|
|
box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
|
|
color: white;
|
|
box-shadow: 0 4px 15px rgba(107, 114, 128, 0.3);
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
transform: translateY(-3px);
|
|
box-shadow: 0 8px 25px rgba(107, 114, 128, 0.5);
|
|
}
|
|
|
|
.btn-danger {
|
|
background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
|
|
color: white;
|
|
box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
|
|
}
|
|
|
|
.btn-danger:hover {
|
|
transform: translateY(-3px);
|
|
box-shadow: 0 8px 25px rgba(220, 53, 69, 0.5);
|
|
}
|
|
|
|
.btn-success {
|
|
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
|
|
color: white;
|
|
box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
|
|
}
|
|
|
|
.btn-success:hover {
|
|
transform: translateY(-3px);
|
|
box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5);
|
|
}
|
|
|
|
.model-list {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
|
gap: 20px;
|
|
}
|
|
|
|
.model-card {
|
|
background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
|
|
border: 1px solid rgba(0,0,0,0.08);
|
|
border-radius: 14px;
|
|
padding: 24px;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.04);
|
|
}
|
|
|
|
.model-card:hover {
|
|
border-color: #667eea;
|
|
box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
|
|
transform: translateY(-5px);
|
|
}
|
|
|
|
.model-card h3 {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
background-clip: text;
|
|
margin-bottom: 12px;
|
|
font-size: 1.2em;
|
|
}
|
|
|
|
.model-info {
|
|
font-size: 0.9em;
|
|
color: #6b7280;
|
|
margin: 6px 0;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.status-badge {
|
|
display: inline-block;
|
|
padding: 6px 16px;
|
|
border-radius: 20px;
|
|
font-size: 0.85em;
|
|
font-weight: 600;
|
|
margin-top: 12px;
|
|
}
|
|
|
|
.status-success {
|
|
background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
|
|
color: #155724;
|
|
box-shadow: 0 2px 8px rgba(21, 87, 36, 0.2);
|
|
}
|
|
|
|
.status-training {
|
|
background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
|
|
color: #856404;
|
|
box-shadow: 0 2px 8px rgba(133, 100, 4, 0.2);
|
|
}
|
|
|
|
.status-error {
|
|
background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
|
|
color: #721c24;
|
|
box-shadow: 0 2px 8px rgba(114, 28, 36, 0.2);
|
|
}
|
|
|
|
.progress-bar {
|
|
width: 100%;
|
|
height: 32px;
|
|
background: linear-gradient(to right, #e5e7eb, #f3f4f6);
|
|
border-radius: 16px;
|
|
overflow: hidden;
|
|
margin: 20px 0;
|
|
box-shadow: inset 0 2px 8px rgba(0,0,0,0.08);
|
|
border: 1px solid rgba(0,0,0,0.05);
|
|
}
|
|
|
|
.progress-fill {
|
|
height: 100%;
|
|
background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #667eea 100%);
|
|
background-size: 200% 100%;
|
|
animation: shimmer 2s infinite;
|
|
transition: width 0.3s;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: white;
|
|
font-weight: 700;
|
|
font-size: 0.9em;
|
|
box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
|
|
}
|
|
|
|
@keyframes shimmer {
|
|
0% { background-position: 200% 0; }
|
|
100% { background-position: -200% 0; }
|
|
}
|
|
|
|
.info-box {
|
|
background: linear-gradient(135deg, #e3f2fd 0%, #f0f7ff 100%);
|
|
border-left: 5px solid #2196F3;
|
|
padding: 20px;
|
|
border-radius: 12px;
|
|
margin-bottom: 20px;
|
|
box-shadow: 0 4px 15px rgba(33, 150, 243, 0.1);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.info-box:hover {
|
|
box-shadow: 0 6px 25px rgba(33, 150, 243, 0.15);
|
|
transform: translateX(3px);
|
|
}
|
|
|
|
.warning-box {
|
|
background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
|
|
border-left: 5px solid #ffc107;
|
|
padding: 20px;
|
|
border-radius: 12px;
|
|
margin-bottom: 20px;
|
|
box-shadow: 0 4px 15px rgba(255, 193, 7, 0.1);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.warning-box:hover {
|
|
box-shadow: 0 6px 25px rgba(255, 193, 7, 0.15);
|
|
transform: translateX(3px);
|
|
}
|
|
|
|
.grid-2 {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 20px;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.grid-2 {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.model-list {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
|
|
.logs {
|
|
background: #1e1e1e;
|
|
color: #d4d4d4;
|
|
padding: 20px;
|
|
border-radius: 12px;
|
|
font-family: 'Courier New', monospace;
|
|
font-size: 0.9em;
|
|
max-height: 400px;
|
|
overflow-y: auto;
|
|
margin-top: 20px;
|
|
box-shadow: inset 0 2px 10px rgba(0,0,0,0.3);
|
|
}
|
|
|
|
.logs .log-entry {
|
|
margin: 5px 0;
|
|
padding: 4px 0;
|
|
}
|
|
|
|
.logs .log-info {
|
|
color: #4ec9b0;
|
|
}
|
|
|
|
.logs .log-warning {
|
|
color: #dcdcaa;
|
|
}
|
|
|
|
.logs .log-error {
|
|
color: #f48771;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<h1>🌥️ Cloud Removal Training</h1>
|
|
<p>Train Deep Learning Models để khử mây từ ảnh Sentinel-2</p>
|
|
</div>
|
|
|
|
<div class="nav">
|
|
<a href="/">← Trang chủ</a>
|
|
<a href="/training">Land Classification</a>
|
|
<a href="/prediction">Prediction</a>
|
|
<a href="#models">Models đã train</a>
|
|
</div>
|
|
|
|
<div class="content">
|
|
<!-- Info Section -->
|
|
<div class="section">
|
|
<div class="info-box">
|
|
<strong>📚 Dataset:</strong> SEN12MS-CR (Sentinel-12 Multi-Seasonal Cloud Removal)<br>
|
|
<strong>🏗️ Architecture:</strong> U-Net với skip connections<br>
|
|
<strong>📊 Input:</strong> S2 cloudy (4 bands) + S1 radar (2 bands) = 6 channels<br>
|
|
<strong>🎯 Output:</strong> S2 clean (4 bands)<br>
|
|
<strong>⏱️ Training time:</strong> ~2-3 hours (GPU) / ~20-30 hours (CPU)
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Training Configuration -->
|
|
<div class="section">
|
|
<h2 class="section-title">⚙️ Cấu hình Training</h2>
|
|
|
|
<div class="card">
|
|
<form id="trainingForm">
|
|
<div class="grid-2">
|
|
<div class="form-group">
|
|
<label>🏗️ Model Architecture</label>
|
|
<select id="modelArchitecture" required>
|
|
<option value="unet">U-Net (Classic CNN)</option>
|
|
<option value="crgan">CR-GAN (Cloud Removal GAN)</option>
|
|
<option value="spagan">SpA-GAN (Spatial Attention GAN)</option>
|
|
<option value="glfcr">GLF-CR (Global-Local Fusion)</option>
|
|
<option value="sen12mscr">SEN12MS-CR (Multi-modal)</option>
|
|
<option value="rsdehazenet">RSDehazeNet (Remote Sensing)</option>
|
|
<option value="cloudnet">Cloud-Net (Encoder-Decoder)</option>
|
|
<option value="dsen2cr">DSen2-CR (Deep Sentinel-2)</option>
|
|
</select>
|
|
<small style="color: #6c757d;">Chọn kiến trúc deep learning cho cloud removal</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>🏷️ Model Name</label>
|
|
<input type="text" id="modelName" value="cloud_removal_unet" required>
|
|
<small style="color: #6c757d;">Tên model để lưu</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>📂 Data Directory</label>
|
|
<input type="text" id="dataDir" value="winter_dataset" required>
|
|
<small style="color: #6c757d;">Thư mục chứa dữ liệu SEN12MS-CR</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>📦 Batch Size</label>
|
|
<input type="number" id="batchSize" value="8" min="1" max="32" required>
|
|
<small style="color: #6c757d;">Giảm xuống 4 hoặc 2 nếu GPU hết RAM</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>🔄 Number of Epochs</label>
|
|
<input type="number" id="numEpochs" value="50" min="1" max="200" required>
|
|
<small style="color: #6c757d;">Số lượng epochs training</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>📈 Learning Rate</label>
|
|
<input type="number" id="learningRate" value="0.0001" step="0.00001" min="0.00001" max="0.01" required>
|
|
<small style="color: #6c757d;">Learning rate (default: 1e-4)</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="checkbox-group">
|
|
<input type="checkbox" id="useS1" checked>
|
|
<label for="useS1">📡 Use Sentinel-1 (Radar Data)</label>
|
|
</div>
|
|
<small style="color: #6c757d;">Sử dụng dữ liệu radar (VV, VH) để cải thiện kết quả</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="checkbox-group">
|
|
<input type="checkbox" id="useGPU" checked>
|
|
<label for="useGPU">🚀 Use GPU</label>
|
|
</div>
|
|
<small style="color: #6c757d;">Sử dụng GPU để training nhanh hơn</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group" style="margin-top: 20px;">
|
|
<button type="submit" class="btn btn-primary">🚀 Start Training</button>
|
|
<button type="button" class="btn btn-secondary" onclick="refreshModels()">🔄 Refresh Models</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Training Status -->
|
|
<div class="section" id="trainingStatus" style="display: none;">
|
|
<h2 class="section-title">📊 Training Status</h2>
|
|
<div class="card">
|
|
<div id="statusMessage"></div>
|
|
<div class="progress-bar">
|
|
<div class="progress-fill" id="progressBar" style="width: 0%;">0%</div>
|
|
</div>
|
|
<div class="logs" id="trainingLogs">
|
|
<div class="log-entry log-info">Training logs will appear here...</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Models List -->
|
|
<div class="section" id="models">
|
|
<h2 class="section-title">🤖 Cloud Removal Models</h2>
|
|
<div class="model-list" id="modelsList">
|
|
<div class="model-card">
|
|
<p style="text-align: center; color: #6c757d;">Loading models...</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Methods Info -->
|
|
<div class="section">
|
|
<h2 class="section-title">📖 Cloud Removal Deep Learning Architectures</h2>
|
|
<div class="grid-2">
|
|
<div class="card">
|
|
<h3>🔹 U-Net</h3>
|
|
<p>Classic encoder-decoder with skip connections. Fast training, good baseline performance.</p>
|
|
<div class="status-badge status-success">Recommended for beginners</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>🔹 CR-GAN</h3>
|
|
<p>Cloud Removal GAN - adversarial training cho kết quả chân thực hơn.</p>
|
|
<div class="status-badge status-training">Advanced</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>🔹 SpA-GAN</h3>
|
|
<p>Spatial Attention GAN - attention mechanism tập trung vào vùng có mây.</p>
|
|
<div class="status-badge status-success">Best quality</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>🔹 GLF-CR</h3>
|
|
<p>Global-Local Fusion - kết hợp features global và local cho chi tiết tốt hơn.</p>
|
|
<div class="status-badge status-training">High accuracy</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>🔹 SEN12MS-CR</h3>
|
|
<p>Multi-modal fusion - kết hợp Sentinel-1 radar và Sentinel-2 optical.</p>
|
|
<div class="status-badge status-success">Multi-sensor</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>🔹 RSDehazeNet</h3>
|
|
<p>Remote Sensing Dehaze Network - chuyên cho ảnh viễn thám.</p>
|
|
<div class="status-badge status-training">RS specialized</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>🔹 Cloud-Net</h3>
|
|
<p>Encoder-Decoder architecture với residual connections.</p>
|
|
<div class="status-badge status-success">Balanced</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>🔹 DSen2-CR</h3>
|
|
<p>Deep Sentinel-2 Cloud Removal - tận dụng temporal information.</p>
|
|
<div class="status-badge status-training">Temporal fusion</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Load models on page load
|
|
window.addEventListener('load', () => {
|
|
refreshModels();
|
|
loadCloudRemovalMethods();
|
|
});
|
|
|
|
// Handle training form submission
|
|
document.getElementById('trainingForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
|
|
const config = {
|
|
data_dir: document.getElementById('dataDir').value,
|
|
model_name: document.getElementById('modelName').value,
|
|
architecture: document.getElementById('modelArchitecture').value,
|
|
use_s1: document.getElementById('useS1').checked,
|
|
batch_size: parseInt(document.getElementById('batchSize').value),
|
|
num_epochs: parseInt(document.getElementById('numEpochs').value),
|
|
learning_rate: parseFloat(document.getElementById('learningRate').value),
|
|
use_gpu: document.getElementById('useGPU').checked
|
|
};
|
|
|
|
try {
|
|
const response = await fetch('/api/cloud-removal/train', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(config)
|
|
});
|
|
|
|
const result = await response.json();
|
|
|
|
if (response.ok) {
|
|
// Show training status section
|
|
document.getElementById('trainingStatus').style.display = 'block';
|
|
document.getElementById('statusMessage').innerHTML = `
|
|
<div class="status-badge status-training">Training Started: ${result.training_id}</div>
|
|
<p style="margin-top: 10px;">Model training has started in background. This may take several hours.</p>
|
|
`;
|
|
|
|
addLog('info', `Training started: ${result.training_id}`);
|
|
addLog('info', `Config: ${JSON.stringify(config, null, 2)}`);
|
|
|
|
// Simulate progress (actual progress would come from websocket)
|
|
simulateProgress();
|
|
} else {
|
|
alert('Error starting training: ' + (result.detail || result.error));
|
|
}
|
|
} catch (error) {
|
|
alert('Error: ' + error.message);
|
|
}
|
|
});
|
|
|
|
// Refresh models list
|
|
async function refreshModels() {
|
|
try {
|
|
const response = await fetch('/api/cloud-removal/models');
|
|
const data = await response.json();
|
|
|
|
const modelsList = document.getElementById('modelsList');
|
|
|
|
if (data.models && data.models.length > 0) {
|
|
modelsList.innerHTML = data.models.map(model => `
|
|
<div class="model-card">
|
|
<h3>📦 ${model.filename}</h3>
|
|
<div class="model-info">🏗️ Architecture: ${model.architecture || 'U-Net'}</div>
|
|
<div class="model-info">📊 Epoch: ${model.epoch}</div>
|
|
<div class="model-info">📉 Train Loss: ${model.train_loss.toFixed(6)}</div>
|
|
<div class="model-info">📉 Val Loss: ${model.val_loss.toFixed(6)}</div>
|
|
<div class="model-info">📡 Use S1: ${model.use_s1 ? 'Yes' : 'No'}</div>
|
|
<div class="model-info">💾 Size: ${model.size_mb.toFixed(2)} MB</div>
|
|
<div class="model-info">📅 Created: ${new Date(model.created * 1000).toLocaleString()}</div>
|
|
<div style="margin-top: 15px;">
|
|
<button class="btn btn-danger" onclick="deleteModel('${model.filename}')">
|
|
🗑️ Delete
|
|
</button>
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
} else {
|
|
modelsList.innerHTML = `
|
|
<div class="model-card">
|
|
<p style="text-align: center; color: #6c757d;">
|
|
No cloud removal models found.<br>
|
|
Train your first model above!
|
|
</p>
|
|
</div>
|
|
`;
|
|
}
|
|
} catch (error) {
|
|
console.error('Error loading models:', error);
|
|
}
|
|
}
|
|
|
|
// Delete model
|
|
async function deleteModel(filename) {
|
|
if (!confirm(`Delete model ${filename}?`)) return;
|
|
|
|
try {
|
|
const response = await fetch(`/api/cloud-removal/models/${filename}`, {
|
|
method: 'DELETE'
|
|
});
|
|
|
|
if (response.ok) {
|
|
alert('Model deleted successfully');
|
|
refreshModels();
|
|
} else {
|
|
const error = await response.json();
|
|
alert('Error deleting model: ' + error.detail);
|
|
}
|
|
} catch (error) {
|
|
alert('Error: ' + error.message);
|
|
}
|
|
}
|
|
|
|
// Load cloud removal methods
|
|
async function loadCloudRemovalMethods() {
|
|
try {
|
|
const response = await fetch('/api/cloud-removal/methods');
|
|
const data = await response.json();
|
|
console.log('Available cloud removal methods:', data.methods);
|
|
} catch (error) {
|
|
console.error('Error loading methods:', error);
|
|
}
|
|
}
|
|
|
|
// Add log entry
|
|
function addLog(type, message) {
|
|
const logs = document.getElementById('trainingLogs');
|
|
const timestamp = new Date().toLocaleTimeString();
|
|
const logClass = type === 'error' ? 'log-error' : (type === 'warning' ? 'log-warning' : 'log-info');
|
|
|
|
const entry = document.createElement('div');
|
|
entry.className = `log-entry ${logClass}`;
|
|
entry.textContent = `[${timestamp}] ${message}`;
|
|
|
|
logs.appendChild(entry);
|
|
logs.scrollTop = logs.scrollHeight;
|
|
}
|
|
|
|
// Simulate progress (replace with real progress tracking)
|
|
function simulateProgress() {
|
|
let progress = 0;
|
|
const interval = setInterval(() => {
|
|
progress += Math.random() * 5;
|
|
if (progress >= 100) {
|
|
progress = 100;
|
|
clearInterval(interval);
|
|
addLog('info', 'Training completed! Check models list below.');
|
|
setTimeout(refreshModels, 2000);
|
|
}
|
|
|
|
const progressBar = document.getElementById('progressBar');
|
|
progressBar.style.width = progress + '%';
|
|
progressBar.textContent = Math.floor(progress) + '%';
|
|
|
|
if (progress % 10 < 5) {
|
|
addLog('info', `Training progress: ${Math.floor(progress)}%`);
|
|
}
|
|
}, 3000);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|