Spaces:
Running
Running
File size: 34,235 Bytes
5e8a306 b26e859 5e8a306 86f022f 5e8a306 b26e859 5e8a306 b26e859 5e8a306 b26e859 5e8a306 b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f 5e8a306 b26e859 5e8a306 b26e859 5e8a306 b26e859 86f022f 5e8a306 86f022f b26e859 86f022f 5e8a306 86f022f b26e859 5e8a306 b26e859 5e8a306 b26e859 5e8a306 b26e859 5e8a306 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f 5e8a306 86f022f 5e8a306 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f b26e859 86f022f 5e8a306 |
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 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 |
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ferramenta de Identificação - ReciclaTech</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">
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/[email protected]"></script>
<style>
.sidebar {
width: 280px;
transition: all 0.3s;
}
.sidebar-collapsed {
width: 80px;
}
.main-content {
margin-left: 280px;
transition: all 0.3s;
}
.main-content-expanded {
margin-left: 80px;
}
.drop-zone {
border: 2px dashed #ccc;
border-radius: 8px;
padding: 40px;
text-align: center;
cursor: pointer;
transition: all 0.3s;
}
.drop-zone.highlight {
border-color: #3b82f6;
background-color: rgba(59, 130, 246, 0.1);
}
.plastic-badge {
font-size: 12px;
padding: 2px 8px;
border-radius: 10px;
font-weight: bold;
}
.plastic-1 { background-color: #FF5733; color: white; }
.plastic-2 { background-color: #33FF57; color: #111; }
.plastic-3 { background-color: #3357FF; color: white; }
.plastic-4 { background-color: #F3FF33; color: #111; }
.plastic-5 { background-color: #FF33F3; color: white; }
.plastic-6 { background-color: #33FFF3; color: #111; }
.plastic-7 { background-color: #8A33FF; color: white; }
.progress-bar {
height: 8px;
background-color: #e0e0e0;
border-radius: 4px;
overflow: hidden;
}
.progress-bar-fill {
height: 100%;
background-color: #3b82f6;
transition: width 0.3s ease;
}
</style>
</head>
<body class="bg-gray-100 font-sans flex">
<!-- Sidebar -->
<div id="sidebar" class="sidebar bg-gray-800 text-white h-screen fixed">
<div class="p-4 flex items-center justify-between border-b border-gray-700">
<div class="flex items-center space-x-2">
<i class="fas fa-recycle text-2xl text-blue-400"></i>
<span id="logo-text" class="font-bold text-lg">ReciclaTech</span>
</div>
<button id="toggle-sidebar" class="text-gray-400 hover:text-white">
<i class="fas fa-bars"></i>
</button>
</div>
<nav class="p-4">
<div class="mb-8">
<div class="text-gray-400 text-xs uppercase font-bold mb-2" id="nav-section-title">Menu Principal</div>
<ul class="space-y-2">
<li>
<a href="#" class="flex items-center space-x-3 p-2 rounded bg-gray-700 text-white">
<i class="fas fa-home w-6 text-center"></i>
<span id="nav-dashboard" class="font-medium">Dashboard</span>
</a>
</li>
<li>
<a href="#" class="flex items-center space-x-3 p-2 rounded hover:bg-gray-700 text-gray-300 hover:text-white">
<i class="fas fa-tasks w-6 text-center"></i>
<span id="nav-processos" class="font-medium">Processos</span>
</a>
</li>
<li>
<a href="#" class="flex items-center space-x-3 p-2 rounded hover:bg-gray-700 text-gray-300 hover:text-white">
<i class="fas fa-warehouse w-6 text-center"></i>
<span id="nav-estoque" class="font-medium">Estoque</span>
</a>
</li>
<li>
<a href="#" class="flex items-center space-x-3 p-2 rounded hover:bg-gray-700 text-gray-300 hover:text-white">
<i class="fas fa-chart-line w-6 text-center"></i>
<span id="nav-relatorios" class="font-medium">Relatórios</span>
</a>
</li>
</ul>
</div>
<div>
<div class="text-gray-400 text-xs uppercase font-bold mb-2" id="tools-section-title">Ferramentas</div>
<ul class="space-y-2">
<li>
<a href="#" class="flex items-center space-x-3 p-2 rounded bg-blue-900 text-white">
<i class="fas fa-camera w-6 text-center"></i>
<span id="nav-identificador" class="font-medium">Identificador</span>
</a>
</li>
<li>
<a href="#" class="flex items-center space-x-3 p-2 rounded hover:bg-gray-700 text-gray-300 hover:text-white">
<i class="fas fa-barcode w-6 text-center"></i>
<span id="nav-etiquetas" class="font-medium">Gerar Etiquetas</span>
</a>
</li>
<li>
<a href="#" class="flex items-center space-x-3 p-2 rounded hover:bg-gray-700 text-gray-300 hover:text-white">
<i class="fas fa-weight w-6 text-center"></i>
<span id="nav-pesagem" class="font-medium">Registro de Pesagem</span>
</a>
</li>
</ul>
</div>
</nav>
<div class="absolute bottom-0 left-0 right-0 p-4 border-t border-gray-700">
<div class="flex items-center space-x-3 p-2 rounded hover:bg-gray-700 text-gray-300 hover:text-white cursor-pointer">
<i class="fas fa-user-circle w-6 text-center"></i>
<span id="nav-perfil" class="font-medium">Perfil do Usuário</span>
</div>
<div class="flex items-center space-x-3 p-2 rounded hover:bg-gray-700 text-gray-300 hover:text-white cursor-pointer">
<i class="fas fa-sign-out-alt w-6 text-center"></i>
<span id="nav-sair" class="font-medium">Sair do Sistema</span>
</div>
</div>
</div>
<!-- Main Content -->
<div id="main-content" class="main-content flex-1 p-6">
<div class="bg-white rounded-lg shadow-md p-6">
<!-- Header -->
<div class="flex justify-between items-center mb-6">
<div>
<h1 class="text-2xl font-bold text-gray-800">Identificador de Plásticos</h1>
<p class="text-gray-600">Ferramenta de classificação automática para materiais eletrônicos</p>
</div>
<div class="flex space-x-3">
<button class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-4 py-2 rounded-lg font-medium flex items-center">
<i class="fas fa-history mr-2"></i> Histórico
</button>
<button class="bg-blue-50 hover:bg-blue-100 text-blue-700 px-4 py-2 rounded-lg font-medium flex items-center">
<i class="fas fa-question-circle mr-2"></i> Ajuda
</button>
</div>
</div>
<!-- Tool Section -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Upload Section -->
<div class="lg:col-span-2">
<div class="bg-gray-50 rounded-lg p-6">
<h2 class="text-lg font-semibold mb-4">Enviar imagem para análise</h2>
<div id="dropZone" class="drop-zone mb-6">
<i class="fas fa-cloud-upload-alt text-4xl text-gray-400 mb-3"></i>
<h3 class="text-lg font-medium mb-1">Arraste e solte a imagem aqui</h3>
<p class="text-gray-500 mb-4">ou clique para selecionar um arquivo</p>
<button id="selectFileBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg font-medium transition">
Selecionar arquivo
</button>
<input type="file" id="fileInput" accept="image/*" class="hidden">
</div>
<div id="previewContainer" class="hidden">
<div class="flex justify-between items-center mb-3">
<h3 class="text-lg font-medium">Pré-visualização</h3>
<button id="cancelBtn" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i> Cancelar
</button>
</div>
<div class="border border-gray-200 rounded-lg p-4">
<img id="imagePreview" src="#" alt="Pré-visualização da imagem" class="max-w-full h-auto rounded mx-auto">
</div>
<button id="analyzeBtn" class="mt-4 w-full bg-blue-600 hover:bg-blue-700 text-white py-3 rounded-lg font-semibold transition">
<i class="fas fa-search mr-2"></i> Analisar Material
</button>
</div>
<div id="loadingIndicator" class="hidden text-center py-8">
<div class="inline-block animate-spin rounded-full h-10 w-10 border-t-2 border-b-2 border-blue-500 mb-4"></div>
<p class="text-gray-600">Analisando o material plástico...</p>
<p class="text-sm text-gray-500 mt-2">Isso pode levar alguns segundos</p>
</div>
</div>
</div>
<!-- Results Section -->
<div>
<div class="bg-gray-50 rounded-lg p-6 h-full">
<h2 class="text-lg font-semibold mb-4">Resultados da Análise</h2>
<div id="resultsContainer" class="hidden">
<div id="resultsContent" class="space-y-4">
<!-- Results will be inserted here by JavaScript -->
</div>
</div>
<div id="emptyState" class="text-center py-8">
<i class="fas fa-microscope text-4xl text-gray-300 mb-3"></i>
<h3 class="text-gray-500 font-medium">Nenhuma análise realizada</h3>
<p class="text-sm text-gray-400 mt-1">Envie uma imagem para identificar o tipo de plástico</p>
</div>
</div>
</div>
</div>
<!-- Recent Analyses -->
<div class="mt-8">
<h2 class="text-lg font-semibold mb-4">Análises Recentes</h2>
<div class="bg-gray-50 rounded-lg p-4 overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-100">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Data/Hora</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Tipo de Plástico</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Confiança</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Origem</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Ações</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">15/06 14:32</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="plastic-badge plastic-1">ABS</span>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<div class="w-16 mr-2">
<div class="progress-bar">
<div class="progress-bar-fill" style="width: 87%"></div>
</div>
</div>
<span class="text-sm text-gray-500">87%</span>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">Teclado Dell</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<button class="text-blue-600 hover:text-blue-800 mr-3">
<i class="fas fa-eye"></i>
</button>
<button class="text-green-600 hover:text-green-800">
<i class="fas fa-tag"></i>
</button>
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">15/06 13:15</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="plastic-badge plastic-3">PVC</span>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<div class="w-16 mr-2">
<div class="progress-bar">
<div class="progress-bar-fill" style="width: 92%"></div>
</div>
</div>
<span class="text-sm text-gray-500">92%</span>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">Cabo de rede</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<button class="text-blue-600 hover:text-blue-800 mr-3">
<i class="fas fa-eye"></i>
</button>
<button class="text-green-600 hover:text-green-800">
<i class="fas fa-tag"></i>
</button>
</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">15/06 11:42</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="plastic-badge plastic-7">PC</span>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<div class="w-16 mr-2">
<div class="progress-bar">
<div class="progress-bar-fill" style="width: 78%"></div>
</div>
</div>
<span class="text-sm text-gray-500">78%</span>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">Tela LCD</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<button class="text-blue-600 hover:text-blue-800 mr-3">
<i class="fas fa-eye"></i>
</button>
<button class="text-green-600 hover:text-green-800">
<i class="fas fa-tag"></i>
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script>
// Model and variables
let model;
let imageToAnalyze;
// DOM elements
const sidebar = document.getElementById('sidebar');
const mainContent = document.getElementById('main-content');
const toggleSidebarBtn = document.getElementById('toggle-sidebar');
const dropZone = document.getElementById('dropZone');
const fileInput = document.getElementById('fileInput');
const selectFileBtn = document.getElementById('selectFileBtn');
const previewContainer = document.getElementById('previewContainer');
const imagePreview = document.getElementById('imagePreview');
const analyzeBtn = document.getElementById('analyzeBtn');
const cancelBtn = document.getElementById('cancelBtn');
const loadingIndicator = document.getElementById('loadingIndicator');
const resultsContainer = document.getElementById('resultsContainer');
const resultsContent = document.getElementById('resultsContent');
const emptyState = document.getElementById('emptyState');
// Toggle sidebar
toggleSidebarBtn.addEventListener('click', () => {
sidebar.classList.toggle('sidebar-collapsed');
mainContent.classList.toggle('main-content-expanded');
// Toggle text elements in sidebar
document.querySelectorAll('[id$="-text"], [id^="nav-"], [id$="-title"]').forEach(el => {
el.classList.toggle('hidden');
});
});
// File selection events
selectFileBtn.addEventListener('click', () => fileInput.click());
fileInput.addEventListener('change', handleFileSelect);
analyzeBtn.addEventListener('click', analyzeImage);
cancelBtn.addEventListener('click', resetTool);
// Drag and drop events
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
dropZone.addEventListener(eventName, preventDefaults, false);
});
function preventDefaults(e) {
e.preventDefault();
e.stopPropagation();
}
['dragenter', 'dragover'].forEach(eventName => {
dropZone.addEventListener(eventName, highlight, false);
});
['dragleave', 'drop'].forEach(eventName => {
dropZone.addEventListener(eventName, unhighlight, false);
});
function highlight() {
dropZone.classList.add('highlight');
}
function unhighlight() {
dropZone.classList.remove('highlight');
}
dropZone.addEventListener('drop', handleDrop, false);
function handleDrop(e) {
const dt = e.dataTransfer;
const files = dt.files;
if (files.length > 0 && files[0].type.match('image.*')) {
handleFile(files[0]);
}
}
function handleFileSelect(e) {
if (e.target.files.length > 0 && e.target.files[0].type.match('image.*')) {
handleFile(e.target.files[0]);
}
}
function handleFile(file) {
const reader = new FileReader();
reader.onload = function(event) {
imagePreview.src = event.target.result;
imageToAnalyze = imagePreview;
previewContainer.style.display = 'block';
dropZone.style.display = 'none';
emptyState.style.display = 'none';
};
reader.readAsDataURL(file);
}
// Load the model when the page loads
async function loadModel() {
try {
console.log('Loading model...');
model = await mobilenet.load();
console.log('Model loaded successfully');
} catch (error) {
console.error('Error loading model:', error);
alert('Erro ao carregar o modelo de IA. Por favor, recarregue a página.');
}
}
// Analyze the image
async function analyzeImage() {
if (!imageToAnalyze) return;
try {
// Show loading indicator
previewContainer.style.display = 'none';
loadingIndicator.style.display = 'block';
resultsContainer.style.display = 'none';
// Wait a bit to show the loading indicator (simulate processing time)
await new Promise(resolve => setTimeout(resolve, 1500));
// Classify the image
const predictions = await model.classify(imageToAnalyze);
// Process results - in a real app, we would have a custom model trained on plastic types
const plasticType = simulatePlasticTypeDetection(predictions);
// Display results
displayResults(plasticType, predictions);
// Add to recent analyses (simulated)
addToRecentAnalyses(plasticType);
} catch (error) {
console.error('Error analyzing image:', error);
showError('Erro ao analisar a imagem. Por favor, tente novamente.');
resetTool();
}
}
// Simulate plastic type detection based on MobileNet predictions
function simulatePlasticTypeDetection(predictions) {
// In a real application, this would be replaced with a custom model trained on plastic types
// Here we're just simulating based on the MobileNet predictions
// Get current time for the analysis
const now = new Date();
const timeString = `${now.getHours()}:${now.getMinutes().toString().padStart(2, '0')}`;
const dateString = `${now.getDate()}/${now.getMonth()+1}`;
// Check if the predictions contain words related to electronics (higher chance of ABS, PC, etc.)
const hasElectronics = predictions.some(p =>
p.className.toLowerCase().includes('computer') ||
p.className.toLowerCase().includes('keyboard') ||
p.className.toLowerCase().includes('monitor') ||
p.className.toLowerCase().includes('electronic')
);
// Check if the predictions contain words related to packaging (higher chance of PP, HIPS, etc.)
const hasPackaging = predictions.some(p =>
p.className.toLowerCase().includes('bottle') ||
p.className.toLowerCase().includes('container') ||
p.className.toLowerCase().includes('packaging')
);
// Check if the predictions contain words related to cables (higher chance of PVC)
const hasCables = predictions.some(p =>
p.className.toLowerCase().includes('cable') ||
p.className.toLowerCase().includes('wire')
);
// Check if the predictions contain words related to screens (higher chance of PC)
const hasScreens = predictions.some(p =>
p.className.toLowerCase().includes('screen') ||
p.className.toLowerCase().includes('monitor') ||
p.className.toLowerCase().includes('display')
);
// Determine the most likely plastic type based on these checks
if (hasElectronics) {
return {
type: 'ABS',
fullName: 'Acrilonitrila Butadieno Estireno',
code: '7',
description: 'Comum em teclados, carcaças de computadores e eletrodomésticos. Resistente ao impacto e fácil de moldar.',
density: '1.04-1.06 g/cm³',
confidence: Math.random() * 0.15 + 0.85, // Random confidence between 85% and 100%
origin: predictions[0].className,
date: dateString,
time: timeString,
badgeClass: 'plastic-1'
};
} else if (hasPackaging) {
return {
type: 'PP',
fullName: 'Polipropileno',
code: '5',
description: 'Presente em baterias, componentes internos e isolantes. Resistente a produtos químicos.',
density: '0.89-0.91 g/cm³',
confidence: Math.random() * 0.15 + 0.85,
origin: predictions[0].className,
date: dateString,
time: timeString,
badgeClass: 'plastic-4'
};
} else if (hasCables) {
return {
type: 'PVC',
fullName: 'Policloreto de Vinila',
code: '3',
description: 'Usado em fios, cabos e revestimentos. Flexível e resistente à chama.',
density: '1.30-1.45 g/cm³',
confidence: Math.random() * 0.15 + 0.85,
origin: predictions[0].className,
date: dateString,
time: timeString,
badgeClass: 'plastic-3'
};
} else if (hasScreens) {
return {
type: 'PC',
fullName: 'Policarbonato',
code: '7',
description: 'Encontrado em CDs, DVDs, lentes e componentes ópticos. Transparente e altamente resistente.',
density: '1.20-1.22 g/cm³',
confidence: Math.random() * 0.15 + 0.85,
origin: predictions[0].className,
date: dateString,
time: timeString,
badgeClass: 'plastic-7'
};
} else {
// Default to HIPS if no specific matches
return {
type: 'HIPS',
fullName: 'Poliestireno de Alto Impacto',
code: '6',
description: 'Usado em monitores, TVs e embalagens. Reconhecível pelo som metálico quando batido.',
density: '1.03-1.06 g/cm³',
confidence: Math.random() * 0.15 + 0.85,
origin: predictions[0].className,
date: dateString,
time: timeString,
badgeClass: 'plastic-2'
};
}
}
// Display the analysis results
function displayResults(plasticType, predictions) {
loadingIndicator.style.display = 'none';
emptyState.style.display = 'none';
// Create results HTML
let html = `
<div class="bg-white border border-gray-200 rounded-lg p-4 mb-4">
<div class="flex justify-between items-start mb-3">
<div>
<span class="${plasticType.badgeClass} plastic-badge">${plasticType.type}</span>
<span class="ml-2 text-sm text-gray-500">Código ${plasticType.code}</span>
</div>
<div class="text-sm text-gray-500">${plasticType.date} ${plasticType.time}</div>
</div>
<h3 class="font-bold text-lg mb-1">${plasticType.fullName}</h3>
<p class="text-sm text-gray-600 mb-3">${plasticType.description}</p>
<div class="flex items-center mb-2">
<div class="w-full mr-2">
<div class="progress-bar">
<div class="progress-bar-fill" style="width: ${Math.round(plasticType.confidence * 100)}%"></div>
</div>
</div>
<span class="text-sm font-medium">${Math.round(plasticType.confidence * 100)}%</span>
</div>
<div class="text-xs text-gray-500 mb-3">Origem identificada: ${plasticType.origin}</div>
<div class="grid grid-cols-2 gap-2">
<button class="bg-blue-50 hover:bg-blue-100 text-blue-700 px-3 py-2 rounded text-sm font-medium">
<i class="fas fa-tag mr-1"></i> Etiquetar
</button>
<button class="bg-gray-50 hover:bg-gray-100 text-gray-700 px-3 py-2 rounded text-sm font-medium">
<i class="fas fa-box mr-1"></i> Armazenar
</button>
</div>
</div>
<div class="bg-white border border-gray-200 rounded-lg p-4">
<h4 class="font-semibold mb-2">Próximos passos recomendados</h4>
<ul class="space-y-2 text-sm">
<li class="flex items-start">
<i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
<span>Separar na área de plásticos tipo ${plasticType.code}</span>
</li>
<li class="flex items-start">
<i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
<span>Registrar no sistema como ${plasticType.type}</span>
</li>
<li class="flex items-start">
<i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
<span>Encaminhar para processo de trituração</span>
</li>
</ul>
</div>
`;
resultsContent.innerHTML = html;
resultsContainer.style.display = 'block';
}
// Simulate adding to recent analyses
function addToRecentAnalyses(plasticType) {
// In a real app, this would be saved to a database
console.log('Analysis saved:', plasticType);
}
// Show error message
function showError(message) {
const html = `
<div class="bg-red-50 border border-red-200 rounded-lg p-4 text-red-700">
<div class="flex items-center">
<i class="fas fa-exclamation-circle mr-2"></i>
<span>${message}</span>
</div>
</div>
`;
resultsContent.innerHTML = html;
resultsContainer.style.display = 'block';
}
// Reset the tool to its initial state
function resetTool() {
fileInput.value = '';
previewContainer.style.display = 'none';
loadingIndicator.style.display = 'none';
resultsContainer.style.display = 'none';
dropZone.style.display = 'block';
emptyState.style.display = 'block';
imageToAnalyze = null;
}
// Initialize the page
document.addEventListener('DOMContentLoaded', () => {
loadModel();
});
</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=Diegobrons/s1" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |