File size: 24,835 Bytes
36a4e9d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Analyse d'Images</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.screen {
display: none;
opacity: 0;
transition: opacity 0.5s ease;
}
.screen.active {
display: block;
opacity: 1;
}
.preview-image {
height: 120px;
object-fit: cover;
transition: all 0.3s ease;
}
.preview-image:hover {
transform: scale(1.05);
}
.upload-area {
border: 2px dashed #cbd5e0;
transition: all 0.3s ease;
}
.upload-area:hover, .upload-area.dragover {
border-color: #4f46e5;
background-color: #f8fafc;
}
.progress-ring__circle {
transition: stroke-dashoffset 0.3s;
transform: rotate(-90deg);
transform-origin: 50% 50%;
}
.result-card {
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
transition: all 0.3s ease;
border-radius: 0.5rem;
overflow: hidden;
}
.result-card:hover {
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
.accordion-header {
cursor: pointer;
padding: 1rem;
transition: background-color 0.2s;
}
.accordion-header:hover {
background-color: #f8fafc;
}
.accordion-content {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease-out;
}
.accordion-content.expanded {
max-height: 1000px;
}
.analysis-compare {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.animate-spin-slow {
animation: spin 3s linear infinite;
}
</style>
</head>
<body class="bg-gray-50 min-h-screen font-sans">
<div class="container mx-auto px-4 py-8">
<header class="mb-12 text-center">
<h1 class="text-3xl md:text-4xl font-bold text-indigo-700 mb-2">Analyse de Masse</h1>
<p class="text-gray-600 max-w-2xl mx-auto">Chargez vos images, lancez l'analyse et visualisez les résultats</p>
</header>
<!-- Écran 1: Téléversement d'images -->
<div id="screen1" class="screen active">
<div class="max-w-4xl mx-auto bg-white rounded-xl shadow-md overflow-hidden p-6 mb-8">
<h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
<i class="fas fa-cloud-upload-alt text-indigo-500 mr-3"></i>
Téléversement des Images
</h2>
<div id="uploadArea" class="upload-area rounded-lg p-8 text-center cursor-pointer mb-6">
<input type="file" id="fileInput" class="hidden" accept="image/*" multiple>
<div class="flex flex-col items-center justify-center">
<i class="fas fa-images text-5xl text-indigo-400 mb-4"></i>
<p class="text-lg text-gray-700 mb-2">Glissez-déposez vos images ici ou cliquez pour sélectionner</p>
<p class="text-sm text-gray-500">Formats supportés: JPG, PNG</p>
<button id="selectFilesBtn" class="mt-4 px-6 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 transition">Sélectionner des fichiers</button>
</div>
</div>
<div id="previewContainer" class="hidden">
<h3 class="text-xl font-medium text-gray-700 mb-4">Prévisualisation des images</h3>
<div id="previewGrid" class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-4 mb-6"></div>
<div class="flex justify-end">
<button id="analyzeBtn" class="px-6 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 transition flex items-center">
<i class="fas fa-play mr-2"></i> Lancer l'analyse
</button>
</div>
</div>
</div>
</div>
<!-- Écran 2: Chargement et analyse -->
<div id="screen2" class="screen">
<div class="max-w-2xl mx-auto bg-white rounded-xl shadow-md overflow-hidden p-8 text-center">
<h2 class="text-2xl font-semibold text-gray-800 mb-8 flex items-center justify-center">
<i class="fas fa-cogs text-indigo-500 mr-3"></i>
Analyse en cours
</h2>
<div class="mb-8 flex justify-center">
<div class="relative w-40 h-40">
<svg class="w-full h-full" viewBox="0 0 100 100">
<circle class="text-gray-200" stroke-width="8" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" />
<circle id="progressCircle" class="text-indigo-500 progress-ring__circle" stroke-width="8" stroke-linecap="round" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" />
</svg>
<div class="absolute inset-0 flex items-center justify-center">
<i class="fas fa-microscope text-4xl text-indigo-500 animate-spin-slow"></i>
</div>
</div>
</div>
<div class="relative pt-1 mb-8">
<div class="flex mb-2 items-center justify-between">
<div>
<span id="progressText" class="text-xs font-semibold inline-block py-1 px-2 uppercase rounded-full text-indigo-600 bg-indigo-200">
0%
</span>
</div>
<div class="text-right">
<span id="progressStatus" class="text-xs font-semibold inline-block text-gray-600">
Initialisation...
</span>
</div>
</div>
<div class="overflow-hidden h-2 mb-4 text-xs flex rounded bg-indigo-200">
<div id="progressBar" style="width:0%" class="shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-indigo-500"></div>
</div>
</div>
<p class="text-gray-600 mb-6" id="statusMessage">Préparation de l'analyse...</p>
<button id="cancelBtn" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-md hover:bg-gray-300 transition">Annuler</button>
</div>
</div>
<!-- Écran 3: Résultats d'analyse -->
<div id="screen3" class="screen">
<div class="max-w-6xl mx-auto">
<div class="bg-white rounded-xl shadow-md overflow-hidden p-6 mb-8">
<div class="flex justify-between items-center mb-6">
<h2 class="text-2xl font-semibold text-gray-800 flex items-center">
<i class="fas fa-chart-bar text-indigo-500 mr-3"></i>
Résultats d'analyse
</h2>
<button id="excelExportBtn" class="px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 transition flex items-center">
<i class="fas fa-file-excel mr-2"></i> Exporter en Excel
</button>
</div>
<div id="resultsContainer">
<!-- Les résultats seront ajoutés ici dynamiquement -->
</div>
<div class="mt-8 flex justify-center">
<button id="newAnalysisBtn" class="px-6 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 transition flex items-center">
<i class="fas fa-redo mr-2"></i> Nouvelle analyse
</button>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Éléments DOM
const screen1 = document.getElementById('screen1');
const screen2 = document.getElementById('screen2');
const screen3 = document.getElementById('screen3');
const fileInput = document.getElementById('fileInput');
const selectFilesBtn = document.getElementById('selectFilesBtn');
const uploadArea = document.getElementById('uploadArea');
const previewContainer = document.getElementById('previewContainer');
const previewGrid = document.getElementById('previewGrid');
const analyzeBtn = document.getElementById('analyzeBtn');
const progressText = document.getElementById('progressText');
const progressBar = document.getElementById('progressBar');
const progressCircle = document.getElementById('progressCircle');
const progressStatus = document.getElementById('progressStatus');
const statusMessage = document.getElementById('statusMessage');
const cancelBtn = document.getElementById('cancelBtn');
const excelExportBtn = document.getElementById('excelExportBtn');
const newAnalysisBtn = document.getElementById('newAnalysisBtn');
const resultsContainer = document.getElementById('resultsContainer');
// Variables
let uploadedFiles = [];
let analysisInProgress = false;
let analysisCanceled = false;
// Événements
selectFilesBtn.addEventListener('click', () => fileInput.click());
uploadArea.addEventListener('click', () => fileInput.click());
uploadArea.addEventListener('dragover', (e) => {
e.preventDefault();
uploadArea.classList.add('dragover');
});
uploadArea.addEventListener('dragleave', () => {
uploadArea.classList.remove('dragover');
});
uploadArea.addEventListener('drop', (e) => {
e.preventDefault();
uploadArea.classList.remove('dragover');
handleFiles(e.dataTransfer.files);
});
fileInput.addEventListener('change', () => {
if (fileInput.files.length > 0) {
handleFiles(fileInput.files);
}
});
analyzeBtn.addEventListener('click', startAnalysis);
cancelBtn.addEventListener('click', cancelAnalysis);
excelExportBtn.addEventListener('click', exportToExcel);
newAnalysisBtn.addEventListener('click', resetApp);
// Fonctions
function handleFiles(files) {
uploadedFiles = Array.from(files)
.filter(file => file.type.startsWith('image/'))
.slice(0, 20); // Limite à 20 fichiers pour cet exemple
if (uploadedFiles.length === 0) {
alert('Veuillez sélectionner des fichiers image valides (JPG, PNG).');
return;
}
// Afficher la prévisualisation
previewGrid.innerHTML = '';
uploadedFiles.forEach((file, index) => {
const reader = new FileReader();
reader.onload = function(e) {
const previewCard = document.createElement('div');
previewCard.className = 'relative group';
previewCard.innerHTML = `
<div class="relative overflow-hidden rounded-lg">
<img src="${e.target.result}" alt="Prévisualisation" class="w-full preview-image rounded-lg">
<div class="absolute inset-0 bg-black bg-opacity-30 flex items-center justify-center opacity-0 group-hover:opacity-100 transition">
<span class="text-white font-medium">Image ${index + 1}</span>
</div>
</div>
<div class="mt-2 text-xs text-gray-600 truncate">${file.name}</div>
`;
previewGrid.appendChild(previewCard);
};
reader.readAsDataURL(file);
});
previewContainer.classList.remove('hidden');
}
function showScreen(screenNumber) {
screen1.classList.remove('active');
screen2.classList.remove('active');
screen3.classList.remove('active');
if (screenNumber === 1) screen1.classList.add('active');
else if (screenNumber === 2) screen2.classList.add('active');
else if (screenNumber === 3) screen3.classList.add('active');
}
function startAnalysis() {
if (uploadedFiles.length === 0) {
alert('Veuillez d\'abord téléverser des images.');
return;
}
showScreen(2);
analysisInProgress = true;
analysisCanceled = false;
let progress = 0;
const statusMessages = [
"Préparation des images...",
"Détection des caractéristiques...",
"Analyse des contours...",
"Calcul des masses...",
"Compilation des résultats..."
];
const interval = setInterval(() => {
if (analysisCanceled) {
clearInterval(interval);
statusMessage.textContent = "Analyse annulée";
progressBar.style.width = '0%';
progressText.textContent = '0%';
setProgressCircle(0);
return;
}
progress += Math.random() * 10;
if (progress > 100) progress = 100;
progressBar.style.width = `${progress}%`;
progressText.textContent = `${Math.round(progress)}%`;
setProgressCircle(progress);
const messageIndex = Math.min(Math.floor(progress / 20), statusMessages.length - 1);
progressStatus.textContent = statusMessages[messageIndex];
statusMessage.textContent = getStatusDetails(messageIndex);
if (progress === 100) {
clearInterval(interval);
analysisInProgress = false;
setTimeout(showResults, 1000);
}
}, 300);
}
function getStatusDetails(index) {
const details = [
"Préparation des images pour l'analyse...",
"Scan des images en cours, détection des éléments visuels...",
"Analyse des contours des objets détectés pour précision accrue...",
"Calcul des masses basé sur les caractéristiques des images...",
"Finalisation de l'analyse, préparation des résultats..."
];
return details[index];
}
function setProgressCircle(percent) {
const circumference = 2 * Math.PI * 40;
const offset = circumference - (percent / 100) * circumference;
progressCircle.style.strokeDasharray = circumference;
progressCircle.style.strokeDashoffset = offset;
}
function cancelAnalysis() {
if (analysisInProgress) {
analysisCanceled = true;
cancelBtn.disabled = true;
cancelBtn.classList.add('opacity-50');
}
}
function showResults() {
showScreen(3);
resultsContainer.innerHTML = '';
uploadedFiles.forEach((file, index) => {
const reader = new FileReader();
reader.onload = function(e) {
// Génération aléatoire de résultats pour la démo
const mass = (Math.random() * 1000).toFixed(2);
const color = getRandomColor();
const resultCard = document.createElement('div');
resultCard.className = 'result-card bg-white rounded-lg overflow-hidden shadow-md mb-4';
resultCard.innerHTML = `
<div class="accordion-header flex justify-between items-center p-4 border-b border-gray-200" onclick="toggleAccordion(this)">
<div class="flex items-center">
<span class="font-medium text-gray-800 mr-2">Image ${index + 1}:</span>
<span class="text-gray-600 text-sm truncate max-w-xs">${file.name}</span>
</div>
<div class="flex items-center">
<span class="text-2xl font-bold mr-3" style="color: ${color}">${mass} g</span>
<i class="fas fa-chevron-down text-gray-400 transform transition-transform"></i>
</div>
</div>
<div class="accordion-content">
<div class="p-4 grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<div class="mb-4">
<h4 class="text-md font-medium text-gray-700 mb-2 flex items-center">
<i class="fas fa-image mr-2 text-indigo-500"></i>
Image originale
</h4>
<img src="${e.target.result}" alt="Image ${index + 1}" class="w-full h-48 object-contain rounded border border-gray-200">
</div>
</div>
<div>
<div class="mb-4">
<h4 class="text-md font-medium text-gray-700 mb-2 flex items-center">
<i class="fas fa-search mr-2 text-indigo-500"></i>
Analyse visuelle
</h4>
<div class="w-full h-48 rounded border border-gray-200 flex items-center justify-center" style="background-color: ${color}20; border-color: ${color}">
<div class="text-center">
<div class="w-32 h-32 rounded-full mx-auto mb-2" style="background-color: ${color}50; border: 2px solid ${color}"></div>
<span class="text-sm font-medium" style="color: ${color}">Zone détectée</span>
</div>
</div>
</div>
<div class="bg-gray-50 p-3 rounded-lg">
<h4 class="text-md font-medium text-gray-700 mb-1 flex items-center">
<i class="fas fa-weight-hanging mr-2 text-indigo-500"></i>
Détails de masse
</h4>
<div class="flex items-center">
<span class="text-xl font-bold mr-2" style="color: ${color}">${mass} g</span>
<span class="text-sm text-gray-500">(valeur estimée)</span>
</div>
</div>
</div>
</div>
</div>
`;
resultsContainer.appendChild(resultCard);
};
reader.readAsDataURL(file);
});
}
function getRandomColor() {
const colors = ['#4F46E5', '#10B981', '#3B82F6', '#F59E0B', '#EF4444'];
return colors[Math.floor(Math.random() * colors.length)];
}
function exportToExcel() {
// Simulation d'export Excel
const exportData = uploadedFiles.map((file, index) => {
return {
'Numéro': index + 1,
'Nom du fichier': file.name,
'Masse détectée (g)': (Math.random() * 1000).toFixed(2)
};
});
// Ici, normalement on utiliserait une bibliothèque comme SheetJS pour générer un vrai fichier Excel
alert('Export Excel simulé. En production, cela générerait un fichier avec:\n\n' +
JSON.stringify(exportData, null, 2));
console.log('Données pour export Excel:', exportData);
}
// Fonction globale pour gérer l'ouverture/fermeture des accordéons
window.toggleAccordion = function(header) {
const content = header.nextElementSibling;
const icon = header.querySelector('i.fa-chevron-down');
if (content.classList.contains('expanded')) {
content.classList.remove('expanded');
icon.style.transform = 'rotate(0deg)';
} else {
content.classList.add('expanded');
icon.style.transform = 'rotate(180deg)';
}
}
function resetApp() {
uploadedFiles = [];
fileInput.value = '';
previewContainer.classList.add('hidden');
previewGrid.innerHTML = '';
showScreen(1);
}
// Initialisation du cercle de progression
setProgressCircle(0);
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=sephi22/stpu" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |