orange / index.html
ccookie's picture
Add 3 files
cc2bcdb verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Citrus Classification System</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>
.gradient-bg {
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}
.citrus-card {
transition: all 0.3s ease;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.citrus-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}
.grade-A {
border-left: 5px solid #10B981;
}
.grade-B {
border-left: 5px solid #F59E0B;
}
.grade-C {
border-left: 5px solid #EF4444;
}
.slider-thumb::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 20px;
height: 20px;
border-radius: 50%;
cursor: pointer;
}
#sizeSlider::-webkit-slider-thumb {
background: #3B82F6;
}
#colorSlider::-webkit-slider-thumb {
background: #F59E0B;
}
#smoothnessSlider::-webkit-slider-thumb {
background: #10B981;
}
#photoPreview {
max-height: 300px;
object-fit: contain;
}
.dropzone {
border: 2px dashed #cbd5e0;
transition: all 0.3s;
}
.dropzone.active {
border-color: #3b82f6;
background-color: #ebf4ff;
}
.analysis-progress {
height: 6px;
background-color: #e5e7eb;
}
.analysis-progress-bar {
height: 100%;
background-color: #3b82f6;
transition: width 0.3s ease;
}
</style>
</head>
<body class="gradient-bg min-h-screen">
<div class="container mx-auto px-4 py-8">
<!-- Header -->
<header class="text-center mb-12">
<h1 class="text-4xl font-bold text-gray-800 mb-2">
<i class="fas fa-lemon text-yellow-400 mr-2"></i>
Citrus Classification System
</h1>
<p class="text-lg text-gray-600 max-w-2xl mx-auto">
Analyze citrus fruits through manual input or photo analysis for quality grading
</p>
</header>
<!-- Main Content -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Input Panel -->
<div class="bg-white rounded-xl shadow-lg p-6 lg:col-span-1">
<h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
<i class="fas fa-sliders-h text-blue-500 mr-2"></i>
Classification Parameters
</h2>
<!-- Tab Navigation -->
<div class="flex border-b mb-6">
<button id="manualTab" class="flex-1 py-2 px-4 font-medium text-blue-600 border-b-2 border-blue-500">
<i class="fas fa-keyboard mr-2"></i>Manual Input
</button>
<button id="photoTab" class="flex-1 py-2 px-4 font-medium text-gray-500">
<i class="fas fa-camera mr-2"></i>Photo Analysis
</button>
</div>
<!-- Manual Input Section -->
<div id="manualInputSection">
<!-- Size Input -->
<div class="mb-6">
<label for="sizeSlider" class="block text-sm font-medium text-gray-700 mb-2 flex items-center">
<i class="fas fa-ruler-vertical text-blue-400 mr-2"></i>
Size (Diameter in cm)
</label>
<input type="range" id="sizeSlider" min="5" max="10" step="0.1" value="7.5"
class="w-full h-2 bg-gray-200 rounded-lg slider-thumb">
<div class="flex justify-between text-xs text-gray-500 mt-1">
<span>5 cm</span>
<span id="sizeValue">7.5 cm</span>
<span>10 cm</span>
</div>
</div>
<!-- Color Input -->
<div class="mb-6">
<label for="colorSlider" class="block text-sm font-medium text-gray-700 mb-2 flex items-center">
<i class="fas fa-palette text-yellow-400 mr-2"></i>
Color (Green to Orange)
</label>
<input type="range" id="colorSlider" min="0" max="100" value="50"
class="w-full h-2 bg-gray-200 rounded-lg slider-thumb">
<div class="flex justify-between text-xs text-gray-500 mt-1">
<span>Green</span>
<span id="colorValue">50%</span>
<span>Orange</span>
</div>
</div>
<!-- Smoothness Input -->
<div class="mb-8">
<label for="smoothnessSlider" class="block text-sm font-medium text-gray-700 mb-2 flex items-center">
<i class="fas fa-hand-paper text-green-400 mr-2"></i>
Skin Smoothness
</label>
<input type="range" id="smoothnessSlider" min="0" max="100" value="50"
class="w-full h-2 bg-gray-200 rounded-lg slider-thumb">
<div class="flex justify-between text-xs text-gray-500 mt-1">
<span>Rough</span>
<span id="smoothnessValue">50%</span>
<span>Smooth</span>
</div>
</div>
</div>
<!-- Photo Analysis Section -->
<div id="photoAnalysisSection" class="hidden">
<div class="mb-4">
<div id="dropzone" class="dropzone rounded-lg p-6 text-center cursor-pointer">
<div class="flex flex-col items-center justify-center py-8">
<i class="fas fa-cloud-upload-alt text-3xl text-gray-400 mb-2"></i>
<p class="text-sm text-gray-600 mb-1">Drag & drop citrus photo here</p>
<p class="text-xs text-gray-500">or click to browse files</p>
</div>
<input type="file" id="photoInput" accept="image/*" class="hidden">
</div>
</div>
<div id="photoPreviewContainer" class="hidden mb-4">
<div class="relative">
<img id="photoPreview" src="#" alt="Preview" class="w-full rounded-lg">
<button id="removePhotoBtn" class="absolute top-2 right-2 bg-white rounded-full p-2 shadow-md hover:bg-gray-100">
<i class="fas fa-times text-gray-600"></i>
</button>
</div>
</div>
<div id="analysisProgress" class="hidden">
<div class="flex justify-between text-sm text-gray-600 mb-1">
<span>Analyzing image...</span>
<span id="progressPercent">0%</span>
</div>
<div class="analysis-progress rounded-full overflow-hidden">
<div id="progressBar" class="analysis-progress-bar" style="width: 0%"></div>
</div>
</div>
<div id="analysisResults" class="hidden">
<div class="bg-gray-50 rounded-lg p-4 mb-4">
<h4 class="font-medium text-gray-700 mb-2">Photo Analysis Results</h4>
<div class="grid grid-cols-3 gap-2 text-sm">
<div>
<p class="text-gray-500">Size</p>
<p id="photoSize" class="font-medium">-</p>
</div>
<div>
<p class="text-gray-500">Color</p>
<p id="photoColor" class="font-medium">-</p>
</div>
<div>
<p class="text-gray-500">Smoothness</p>
<p id="photoSmoothness" class="font-medium">-</p>
</div>
</div>
</div>
</div>
</div>
<!-- Classify Button -->
<button id="classifyBtn" class="w-full bg-blue-500 hover:bg-blue-600 text-white font-medium py-3 px-4 rounded-lg transition duration-300 flex items-center justify-center">
<i class="fas fa-cogs mr-2"></i>
Classify Citrus
</button>
</div>
<!-- Results Panel -->
<div class="bg-white rounded-xl shadow-lg p-6 lg:col-span-2">
<h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
<i class="fas fa-chart-bar text-purple-500 mr-2"></i>
Classification Results
</h2>
<!-- Grade Standards -->
<div class="mb-8">
<h3 class="text-lg font-medium text-gray-700 mb-3">Grading Standards</h3>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div class="bg-gray-50 p-4 rounded-lg grade-A">
<h4 class="font-semibold text-green-600 flex items-center">
<i class="fas fa-star mr-2"></i> Grade A (Premium)
</h4>
<ul class="text-sm text-gray-600 mt-2 space-y-1">
<li><i class="fas fa-check-circle text-green-400 mr-1"></i> Size: 8-10 cm</li>
<li><i class="fas fa-check-circle text-green-400 mr-1"></i> Color: 70-100% orange</li>
<li><i class="fas fa-check-circle text-green-400 mr-1"></i> Smoothness: 80-100%</li>
</ul>
</div>
<div class="bg-gray-50 p-4 rounded-lg grade-B">
<h4 class="font-semibold text-yellow-600 flex items-center">
<i class="fas fa-star-half-alt mr-2"></i> Grade B (Standard)
</h4>
<ul class="text-sm text-gray-600 mt-2 space-y-1">
<li><i class="fas fa-check-circle text-yellow-400 mr-1"></i> Size: 6-8 cm</li>
<li><i class="fas fa-check-circle text-yellow-400 mr-1"></i> Color: 30-70% orange</li>
<li><i class="fas fa-check-circle text-yellow-400 mr-1"></i> Smoothness: 50-80%</li>
</ul>
</div>
<div class="bg-gray-50 p-4 rounded-lg grade-C">
<h4 class="font-semibold text-red-600 flex items-center">
<i class="far fa-star mr-2"></i> Grade C (Utility)
</h4>
<ul class="text-sm text-gray-600 mt-2 space-y-1">
<li><i class="fas fa-check-circle text-red-400 mr-1"></i> Size: 5-6 cm</li>
<li><i class="fas fa-check-circle text-red-400 mr-1"></i> Color: 0-30% orange</li>
<li><i class="fas fa-check-circle text-red-400 mr-1"></i> Smoothness: 0-50%</li>
</ul>
</div>
</div>
</div>
<!-- Results Display -->
<div id="resultsContainer" class="hidden">
<h3 class="text-lg font-medium text-gray-700 mb-3">Current Classification</h3>
<div class="bg-gray-50 rounded-lg p-6">
<div class="flex flex-col md:flex-row items-center justify-between">
<div class="flex items-center mb-4 md:mb-0">
<div id="citrusVisual" class="w-20 h-20 rounded-full bg-orange-300 border-4 border-orange-200 mr-4"></div>
<div>
<h4 id="gradeTitle" class="text-xl font-semibold"></h4>
<p id="gradeDescription" class="text-sm text-gray-600"></p>
</div>
</div>
<div id="gradeBadge" class="px-4 py-2 rounded-full text-white font-medium text-lg"></div>
</div>
<div class="mt-6 grid grid-cols-1 md:grid-cols-3 gap-4">
<div class="bg-white p-3 rounded-lg shadow-sm">
<p class="text-xs text-gray-500">Size</p>
<p id="resultSize" class="font-medium"></p>
<div class="w-full bg-gray-200 rounded-full h-2 mt-1">
<div id="sizeBar" class="h-2 rounded-full bg-blue-500"></div>
</div>
</div>
<div class="bg-white p-3 rounded-lg shadow-sm">
<p class="text-xs text-gray-500">Color</p>
<p id="resultColor" class="font-medium"></p>
<div class="w-full bg-gray-200 rounded-full h-2 mt-1">
<div id="colorBar" class="h-2 rounded-full bg-yellow-500"></div>
</div>
</div>
<div class="bg-white p-3 rounded-lg shadow-sm">
<p class="text-xs text-gray-500">Smoothness</p>
<p id="resultSmoothness" class="font-medium"></p>
<div class="w-full bg-gray-200 rounded-full h-2 mt-1">
<div id="smoothnessBar" class="h-2 rounded-full bg-green-500"></div>
</div>
</div>
</div>
</div>
</div>
<!-- MATLAB-style Visualization -->
<div id="matlabViz" class="mt-8 hidden">
<h3 class="text-lg font-medium text-gray-700 mb-3">Classification Visualization</h3>
<div class="bg-gray-800 rounded-lg p-4">
<div class="flex items-center text-green-400 font-mono text-sm mb-2">
<span class="mr-2">>></span>
<span>Citrus Classification Algorithm Output:</span>
</div>
<div id="matlabOutput" class="bg-black text-green-400 p-3 rounded font-mono text-sm overflow-x-auto"></div>
</div>
</div>
</div>
</div>
<!-- Footer -->
<footer class="mt-12 text-center text-gray-500 text-sm">
<p>© 2023 Citrus Classification System | Designed with MATLAB-inspired interface</p>
</footer>
</div>
<script>
// Update slider values in real-time
document.getElementById('sizeSlider').addEventListener('input', function() {
document.getElementById('sizeValue').textContent = this.value + ' cm';
});
document.getElementById('colorSlider').addEventListener('input', function() {
document.getElementById('colorValue').textContent = this.value + '%';
});
document.getElementById('smoothnessSlider').addEventListener('input', function() {
document.getElementById('smoothnessValue').textContent = this.value + '%';
});
// Tab switching
document.getElementById('manualTab').addEventListener('click', function() {
document.getElementById('manualInputSection').classList.remove('hidden');
document.getElementById('photoAnalysisSection').classList.add('hidden');
this.classList.add('text-blue-600', 'border-blue-500');
this.classList.remove('text-gray-500');
document.getElementById('photoTab').classList.add('text-gray-500');
document.getElementById('photoTab').classList.remove('text-blue-600', 'border-blue-500');
});
document.getElementById('photoTab').addEventListener('click', function() {
document.getElementById('manualInputSection').classList.add('hidden');
document.getElementById('photoAnalysisSection').classList.remove('hidden');
this.classList.add('text-blue-600', 'border-blue-500');
this.classList.remove('text-gray-500');
document.getElementById('manualTab').classList.add('text-gray-500');
document.getElementById('manualTab').classList.remove('text-blue-600', 'border-blue-500');
});
// Photo upload functionality
const dropzone = document.getElementById('dropzone');
const photoInput = document.getElementById('photoInput');
const photoPreview = document.getElementById('photoPreview');
const photoPreviewContainer = document.getElementById('photoPreviewContainer');
const removePhotoBtn = document.getElementById('removePhotoBtn');
const analysisProgress = document.getElementById('analysisProgress');
const analysisResults = document.getElementById('analysisResults');
// Handle 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('active');
}
function unhighlight() {
dropzone.classList.remove('active');
}
// Handle dropped files
dropzone.addEventListener('drop', handleDrop, false);
function handleDrop(e) {
const dt = e.dataTransfer;
const files = dt.files;
handleFiles(files);
}
// Handle clicked files
photoInput.addEventListener('change', function() {
handleFiles(this.files);
});
dropzone.addEventListener('click', function() {
photoInput.click();
});
// Remove photo
removePhotoBtn.addEventListener('click', function(e) {
e.stopPropagation();
photoPreview.src = '#';
photoPreviewContainer.classList.add('hidden');
analysisProgress.classList.add('hidden');
analysisResults.classList.add('hidden');
});
function handleFiles(files) {
if (files.length > 0) {
const file = files[0];
if (file.type.match('image.*')) {
const reader = new FileReader();
reader.onload = function(e) {
photoPreview.src = e.target.result;
photoPreviewContainer.classList.remove('hidden');
analyzeImage(file);
}
reader.readAsDataURL(file);
}
}
}
// Simulate image analysis
function analyzeImage(file) {
analysisProgress.classList.remove('hidden');
analysisResults.classList.add('hidden');
let progress = 0;
const progressInterval = setInterval(() => {
progress += Math.random() * 10;
if (progress > 100) progress = 100;
document.getElementById('progressBar').style.width = `${progress}%`;
document.getElementById('progressPercent').textContent = `${Math.floor(progress)}%`;
if (progress === 100) {
clearInterval(progressInterval);
setTimeout(() => {
// Simulate analysis results
const simulatedSize = (5 + Math.random() * 5).toFixed(1);
const simulatedColor = Math.floor(Math.random() * 100);
const simulatedSmoothness = Math.floor(Math.random() * 100);
document.getElementById('photoSize').textContent = `${simulatedSize} cm`;
document.getElementById('photoColor').textContent = `${simulatedColor}% orange`;
document.getElementById('photoSmoothness').textContent = `${simulatedSmoothness}% smooth`;
// Update sliders with analyzed values
document.getElementById('sizeSlider').value = simulatedSize;
document.getElementById('colorSlider').value = simulatedColor;
document.getElementById('smoothnessSlider').value = simulatedSmoothness;
document.getElementById('sizeValue').textContent = `${simulatedSize} cm`;
document.getElementById('colorValue').textContent = `${simulatedColor}%`;
document.getElementById('smoothnessValue').textContent = `${simulatedSmoothness}%`;
analysisProgress.classList.add('hidden');
analysisResults.classList.remove('hidden');
}, 500);
}
}, 100);
}
// Classification function
document.getElementById('classifyBtn').addEventListener('click', function() {
// Get input values
const size = parseFloat(document.getElementById('sizeSlider').value);
const color = parseInt(document.getElementById('colorSlider').value);
const smoothness = parseInt(document.getElementById('smoothnessSlider').value);
// Determine grade
let grade, title, description, badgeClass;
if ((size >= 8 && size <= 10) && (color >= 70 && color <= 100) && (smoothness >= 80 && smoothness <= 100)) {
grade = 'A';
title = 'Premium Quality Citrus';
description = 'Excellent size, color, and texture. Ideal for fresh consumption.';
badgeClass = 'bg-green-500';
}
else if ((size >= 6 && size < 8) && (color >= 30 && color < 70) && (smoothness >= 50 && smoothness < 80)) {
grade = 'B';
title = 'Standard Quality Citrus';
description = 'Good quality, suitable for both fresh consumption and processing.';
badgeClass = 'bg-yellow-500';
}
else if ((size >= 5 && size < 6) && (color >= 0 && color < 30) && (smoothness >= 0 && smoothness < 50)) {
grade = 'C';
title = 'Utility Grade Citrus';
description = 'Best suited for processing into juices or other products.';
badgeClass = 'bg-red-500';
}
else {
grade = 'B';
title = 'Standard Quality Citrus (Mixed Characteristics)';
description = 'Some characteristics meet premium standards while others are utility grade.';
badgeClass = 'bg-yellow-500';
}
// Update citrus visual
const citrusVisual = document.getElementById('citrusVisual');
const colorValue = color / 100;
const orangeHue = 30 + (colorValue * 30); // Range from 30 (greenish) to 60 (orange)
citrusVisual.style.backgroundColor = `hsl(${orangeHue}, 100%, ${70 - (smoothness/100 * 20)}%)`;
// Update results
document.getElementById('gradeTitle').textContent = title;
document.getElementById('gradeDescription').textContent = description;
document.getElementById('gradeBadge').textContent = `Grade ${grade}`;
document.getElementById('gradeBadge').className = `px-4 py-2 rounded-full text-white font-medium text-lg ${badgeClass}`;
// Update metric displays
document.getElementById('resultSize').textContent = `${size.toFixed(1)} cm`;
document.getElementById('resultColor').textContent = `${color}% orange`;
document.getElementById('resultSmoothness').textContent = `${smoothness}% smooth`;
// Update progress bars
document.getElementById('sizeBar').style.width = `${((size - 5) / 5) * 100}%`;
document.getElementById('colorBar').style.width = `${color}%`;
document.getElementById('smoothnessBar').style.width = `${smoothness}%`;
// Show results
document.getElementById('resultsContainer').classList.remove('hidden');
// Generate MATLAB-style output
generateMatlabOutput(size, color, smoothness, grade);
document.getElementById('matlabViz').classList.remove('hidden');
});
function generateMatlabOutput(size, color, smoothness, grade) {
const output = document.getElementById('matlabOutput');
output.innerHTML = `
<div>>> citrus_features = [${size.toFixed(1)}, ${color}, ${smoothness}];</div>
<div>>> grade = classifyCitrus(citrus_features);</div>
<div class="mt-2">Processing feature vector...</div>
<div>Size component: ${size.toFixed(1)} cm → ${getSizeCategory(size)}</div>
<div>Color component: ${color}% orange → ${getColorCategory(color)}</div>
<div>Smoothness component: ${smoothness}% → ${getSmoothnessCategory(smoothness)}</div>
<div class="mt-2 font-bold">Classification result: Grade ${grade}</div>
<div class="mt-1">Confidence: ${calculateConfidence(size, color, smoothness, grade).toFixed(1)}%</div>
`;
}
function getSizeCategory(size) {
if (size >= 8) return 'Premium range';
if (size >= 6) return 'Standard range';
return 'Utility range';
}
function getColorCategory(color) {
if (color >= 70) return 'Premium color';
if (color >= 30) return 'Standard color';
return 'Utility color';
}
function getSmoothnessCategory(smoothness) {
if (smoothness >= 80) return 'Premium texture';
if (smoothness >= 50) return 'Standard texture';
return 'Utility texture';
}
function calculateConfidence(size, color, smoothness, grade) {
// Simple confidence calculation based on how close features are to grade center
let sizeScore, colorScore, smoothnessScore;
if (grade === 'A') {
sizeScore = Math.min(100, Math.max(0, (size - 8) / 2 * 100));
colorScore = Math.min(100, Math.max(0, (color - 70) / 30 * 100));
smoothnessScore = Math.min(100, Math.max(0, (smoothness - 80) / 20 * 100));
}
else if (grade === 'B') {
sizeScore = 100 - Math.abs(size - 7) / 1 * 100;
colorScore = 100 - Math.abs(color - 50) / 20 * 100;
smoothnessScore = 100 - Math.abs(smoothness - 65) / 15 * 100;
}
else {
sizeScore = Math.min(100, Math.max(0, (6 - size) / 1 * 100));
colorScore = Math.min(100, Math.max(0, (30 - color) / 30 * 100));
smoothnessScore = Math.min(100, Math.max(0, (50 - smoothness) / 50 * 100));
}
return (sizeScore + colorScore + smoothnessScore) / 3;
}
</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=ccookie/orange" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>