325 lines
14 KiB
HTML
325 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<meta charset="utf-8" />
|
|
<link rel="stylesheet" href="globals.css" />
|
|
<link rel="stylesheet" href="styleguide.css" />
|
|
<link rel="stylesheet" href="style.css" />
|
|
<style>
|
|
#projects-list {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 15px;
|
|
justify-content: flex-start;
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.dataset-card {
|
|
flex: 0 0 auto;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body onload="pollStatus()">
|
|
<div>
|
|
<div id="header">
|
|
<icon class="header-icon" onclick="window.location.href='/index.html'" , onmouseover="" style="cursor: pointer;"
|
|
src="./media/logo.png" alt="Logo"></icon>
|
|
<label id="project-title-label"
|
|
style="display: block; text-align: left; font-weight: bold; font-size: x-large;">Project</label>
|
|
<div class="button-row">
|
|
<button id="Add Training Project" onclick="window.location.href='/add-project.html'" class="button-red">Add
|
|
Training Project</button>
|
|
<button id="seed-db-btn" class="button">
|
|
Seed Database
|
|
<div class="loader" id="loader" style="display: none"></div>
|
|
|
|
</button>
|
|
<button id="settings-btn" onclick="window.openSettingsModal()" class="button" title="Einstellungen" style="padding: 8px 12px; margin-left: 10px;">⚙️</button>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</button>
|
|
|
|
</button>
|
|
<button id="setup-details" class="button">
|
|
Show Details
|
|
</button>
|
|
|
|
<script>
|
|
document.getElementById('seed-db-btn').addEventListener('click', function () {
|
|
const elLoader = document.getElementById("loader")
|
|
elLoader.style.display = "inherit"
|
|
|
|
fetch('/api/seed')
|
|
.finally(() => {
|
|
// Instead of hiding loader immediately, poll /api/update-status until done
|
|
function pollStatus() {
|
|
fetch('/api/update-status')
|
|
.then(res => res.json())
|
|
.then(status => {
|
|
if (status && status.running) {
|
|
// Still running, poll again after short delay
|
|
setTimeout(pollStatus, 5000);
|
|
} else {
|
|
elLoader.style.display = "none";
|
|
}
|
|
})
|
|
.catch(() => {
|
|
elLoader.style.display = "none";
|
|
});
|
|
}
|
|
pollStatus();
|
|
})
|
|
});
|
|
|
|
// Show loader if backend is still processing on page load
|
|
|
|
function pollStatus() {
|
|
const elLoader = document.getElementById("loader");
|
|
fetch('/api/update-status')
|
|
.then(res => res.json())
|
|
|
|
.then(status => {
|
|
if (status && status.running) {
|
|
elLoader.style.display = "inherit";
|
|
setTimeout(pollStatus, 5000);
|
|
} else {
|
|
elLoader.style.display = "none";
|
|
}
|
|
})
|
|
.catch(() => {
|
|
elLoader.style.display = "none";
|
|
});
|
|
}
|
|
|
|
</script>
|
|
<script>
|
|
// Declare urlParams and projectId once
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const projectId = urlParams.get('id');
|
|
// Set project title in header
|
|
fetch('/api/training-projects')
|
|
.then(res => res.json())
|
|
.then(projects => {
|
|
const project = projects.find(p => p.project_id == projectId || p.id == projectId);
|
|
if (project) {
|
|
const titleLabel = document.getElementById('project-title-label');
|
|
if (titleLabel) titleLabel.textContent = '/' + project.title;
|
|
}
|
|
});
|
|
// Render trainings
|
|
function renderTrainings(trainings) {
|
|
const list = document.getElementById('projects-list');
|
|
list.innerHTML = '';
|
|
if (!Array.isArray(trainings) || trainings.length === 0) {
|
|
list.innerHTML = '<div style="color:#009eac;padding:16px;">No trainings found for this project.</div>';
|
|
return;
|
|
}
|
|
trainings.forEach(training => {
|
|
const card = document.createElement('div');
|
|
card.className = 'dataset-card';
|
|
card.style = 'border:1px solid #009eac;padding:12px;margin:8px;border-radius:8px;background:#eaf7fa;position:relative;min-width:320px;min-height:120px;display:flex;flex-direction:row;justify-content:space-between;align-items:stretch;';
|
|
|
|
// Info section (left)
|
|
const infoDiv = document.createElement('div');
|
|
infoDiv.style = 'flex:1; text-align:left;';
|
|
infoDiv.innerHTML = `<b>${training.exp_name || 'Training'}</b><br>Epochs: ${training.max_epoch}<br>Depth: ${training.depth}<br>Width: ${training.width}<br>Activation: ${training.activation || training.act || ''}`;
|
|
|
|
// Buttons section (right)
|
|
const btnDiv = document.createElement('div');
|
|
btnDiv.style = 'display:flex;flex-direction:column;align-items:flex-end;gap:8px;min-width:160px;';
|
|
|
|
// Start Training button
|
|
const startBtn = document.createElement('button');
|
|
startBtn.textContent = 'Start YOLOX Training';
|
|
startBtn.style = 'background:#009eac;color:white;border:none;border-radius:6px;padding:6px 12px;cursor:pointer;';
|
|
startBtn.onclick = function() {
|
|
startBtn.disabled = true;
|
|
fetch('/api/start-yolox-training', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ project_id: projectId, training_id: training.id })
|
|
})
|
|
.then(res => res.json())
|
|
.then(result => {
|
|
alert(result.message || 'Training started');
|
|
startBtn.disabled = false;
|
|
})
|
|
.catch(() => {
|
|
alert('Failed to start training');
|
|
startBtn.disabled = false;
|
|
});
|
|
};
|
|
btnDiv.appendChild(startBtn);
|
|
|
|
// View Log button
|
|
const logBtn = document.createElement('button');
|
|
logBtn.textContent = 'View Training Log';
|
|
logBtn.style = 'background:#666;color:white;border:none;border-radius:6px;padding:6px 12px;cursor:pointer;';
|
|
logBtn.onclick = function() {
|
|
showLogModal(training.id);
|
|
};
|
|
btnDiv.appendChild(logBtn);
|
|
|
|
// Remove button
|
|
const removeBtn = document.createElement('button');
|
|
removeBtn.textContent = 'Remove';
|
|
removeBtn.style = 'background:#ff4d4f;color:white;border:none;border-radius:6px;padding:6px 12px;cursor:pointer;';
|
|
removeBtn.onclick = function() {
|
|
if (confirm('Are you sure you want to delete this training?')) {
|
|
fetch(`/api/trainings/${training.id}`, { method: 'DELETE' })
|
|
.then(res => res.json())
|
|
.then(result => {
|
|
alert(result.message || 'Training deleted');
|
|
fetchTrainings(); // Refresh list
|
|
})
|
|
.catch(() => alert('Failed to delete training'));
|
|
}
|
|
};
|
|
btnDiv.appendChild(removeBtn);
|
|
|
|
card.appendChild(infoDiv);
|
|
card.appendChild(btnDiv);
|
|
list.appendChild(card);
|
|
});
|
|
// Modal for log display
|
|
if (!document.getElementById('log-modal')) {
|
|
const modal = document.createElement('div');
|
|
modal.id = 'log-modal';
|
|
modal.style = 'display:none;position:fixed;top:0;left:0;width:100vw;height:100vh;background:rgba(0,0,0,0.5);z-index:9999;justify-content:center;align-items:center;';
|
|
modal.innerHTML = `<div style="background:#fff;padding:24px;border-radius:8px;max-width:800px;width:90vw;max-height:80vh;overflow:auto;position:relative;"><pre id='log-content' style='font-size:13px;white-space:pre-wrap;word-break:break-all;max-height:60vh;overflow:auto;background:#f7f7f7;padding:12px;border-radius:6px;'></pre><button id='close-log-modal' style='position:absolute;top:8px;right:8px;background:#009eac;color:#fff;border:none;border-radius:4px;padding:6px 12px;cursor:pointer;'>Close</button></div>`;
|
|
document.body.appendChild(modal);
|
|
document.getElementById('close-log-modal').onclick = function() {
|
|
modal.style.display = 'none';
|
|
};
|
|
}
|
|
|
|
// Function to show log modal and poll log
|
|
function showLogModal(trainingId) {
|
|
const modal = document.getElementById('log-modal');
|
|
const logContent = document.getElementById('log-content');
|
|
modal.style.display = 'flex';
|
|
function fetchLog() {
|
|
fetch(`/api/training-log?project_id=${projectId}&training_id=${trainingId}`)
|
|
.then(res => res.json())
|
|
.then(data => {
|
|
logContent.textContent = data.log || 'No log found.';
|
|
})
|
|
.catch(() => {
|
|
logContent.textContent = 'Failed to fetch log.';
|
|
});
|
|
}
|
|
fetchLog();
|
|
// Poll every 5 seconds while modal is open
|
|
let poller = setInterval(() => {
|
|
if (modal.style.display === 'flex') fetchLog();
|
|
else clearInterval(poller);
|
|
}, 5000);
|
|
}
|
|
}
|
|
// Fetch trainings for project
|
|
function fetchTrainings() {
|
|
if (!projectId) return;
|
|
fetch(`/api/trainings?project_id=${projectId}`)
|
|
.then(res => res.json())
|
|
.then(trainings => {
|
|
renderTrainings(trainings);
|
|
});
|
|
}
|
|
window.addEventListener('DOMContentLoaded', fetchTrainings);
|
|
</script>
|
|
<div style="padding: 16px; text-align: left;">
|
|
<button id="create-new-training-btn" class="button" style="background:#009eac;color:white;">
|
|
+ Create New Training
|
|
</button>
|
|
</div>
|
|
<div id="projects-list"></div>
|
|
</div>
|
|
|
|
<script>
|
|
// Create New Training button handler
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
document.getElementById('create-new-training-btn').addEventListener('click', function() {
|
|
if (!projectId) {
|
|
alert('No project selected');
|
|
return;
|
|
}
|
|
// Navigate to edit-training page to configure new training parameters
|
|
// This will reuse existing project details and class mappings
|
|
window.location.href = `/edit-training.html?project_id=${projectId}`;
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<!-- Settings Modal -->
|
|
<div id="settings-modal" class="modal" style="display: none;">
|
|
<div class="modal-content" style="max-width: 600px; max-height: 90vh; overflow-y: auto;">
|
|
<div class="modal-header">
|
|
<h2>Einstellungen</h2>
|
|
<button class="close-btn" onclick="window.closeSettingsModal()">×</button>
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
<!-- Label Studio Settings -->
|
|
<div class="settings-section">
|
|
<h3>Label Studio</h3>
|
|
<div class="form-group">
|
|
<label for="labelstudio-url">API URL:</label>
|
|
<input type="text" id="labelstudio-url" placeholder="http://192.168.1.19:8080">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="labelstudio-token">API Token:</label>
|
|
<input type="password" id="labelstudio-token" placeholder="API Token">
|
|
</div>
|
|
<button id="test-labelstudio-btn" class="button">
|
|
Verbindung testen
|
|
<div class="loader" id="test-ls-loader" style="display: none"></div>
|
|
</button>
|
|
<div id="labelstudio-status" class="status-message"></div>
|
|
</div>
|
|
|
|
<!-- YOLOX Settings -->
|
|
<div class="settings-section">
|
|
<h3>YOLOX</h3>
|
|
<div class="form-group">
|
|
<label for="yolox-path">Installation Path:</label>
|
|
<input type="text" id="yolox-path" placeholder="C:/YOLOX">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="yolox-venv-path">Virtual Environment Path:</label>
|
|
<input type="text" id="yolox-venv-path" placeholder="/path/to/venv/bin/activate">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="yolox-output-path">Output Folder:</label>
|
|
<input type="text" id="yolox-output-path" placeholder="./backend">
|
|
<small style="display: block; margin-top: 4px; color: #666;">Folder for experiment files and JSON files</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="yolox-data-dir">Data Directory:</label>
|
|
<input type="text" id="yolox-data-dir" placeholder="/home/kitraining/To_Annotate/">
|
|
<small style="display: block; margin-top: 4px; color: #666;">Path where training images are located</small>
|
|
</div>
|
|
<button id="test-yolox-btn" class="button">
|
|
Pfad überprüfen
|
|
<div class="loader" id="test-yolox-loader" style="display: none"></div>
|
|
</button>
|
|
<div id="yolox-status" class="status-message"></div>
|
|
</div>
|
|
|
|
<!-- Save Button -->
|
|
<div class="settings-section">
|
|
<button id="save-settings-btn" class="button-red">Einstellungen speichern</button>
|
|
<div id="save-status" class="status-message"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="js/settings.js"></script>
|
|
</body>
|
|
|
|
</html> |