image-configuration / index.html
MarcRyan's picture
Add 3 files
96c37d2 verified
Raw History Blame Contribute Delete
58.5 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>UNO-FLUX Image Processing Dashboard</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> @keyframes gradientFlow { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } } .gradient-bg { background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab); background-size: 400% 400%; animation: gradientFlow 15s ease infinite; } .card-3d { transform-style: preserve-3d; transition: all 0.5s ease; } .card-3d:hover { transform: rotateY(10deg) rotateX(5deg) translateY(-5px); box-shadow: 0 20px 30px rgba(0,0,0,0.2); } .glow-effect { box-shadow: 0 0 15px rgba(59, 130, 246, 0.5); } .input-highlight { transition: all 0.3s ease; border-bottom: 2px solid transparent; } .input-highlight:focus { border-bottom: 2px solid #3b82f6; box-shadow: none; } .wave-pattern { background-image: radial-gradient(circle at 10% 20%, rgba(255,255,255,0.1) 0%, transparent 20%); } /* Custom file upload button */ .file-upload { position: relative; overflow: hidden; display: inline-block; } .file-upload input[type="file"] { position: absolute; left: 0; top: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; } /* Tab styling */ .tab-button.active { border-bottom: 2px solid #3b82f6; opacity: 1; } /* Toast notification */ .toast { position: fixed; bottom: 20px; right: 20px; background: rgba(0,0,0,0.8); color: white; padding: 12px 24px; border-radius: 8px; transform: translateY(100px); opacity: 0; transition: all 0.3s ease; z-index: 1000; } .toast.show { transform: translateY(0); opacity: 1; } /* Image preview */ .image-preview { max-width: 100%; max-height: 300px; object-fit: contain; border-radius: 8px; display: none; } /* Filter buttons */ .filter-btn { transition: all 0.2s ease; } .filter-btn:hover { transform: scale(1.05); } .filter-btn.active { background-color: #3b82f6 !important; color: white !important; } /* Loading spinner */ .spinner { width: 24px; height: 24px; border: 3px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: white; animation: spin 1s ease-in-out infinite; display: none; } @keyframes spin { to { transform: rotate(360deg); } } /* Before/after slider */ .ba-slider { position: relative; overflow: hidden; border-radius: 8px; } .ba-slider img { width: 100%; display: block; } .resize { position: absolute; top: 0; left: 0; height: 100%; width: 50%; overflow: hidden; } .handle { position: absolute; left: 50%; top: 0; bottom: 0; width: 4px; margin-left: -2px; background: rgba(255,255,255,0.7); cursor: ew-resize; } .handle:after { position: absolute; top: 50%; width: 32px; height: 32px; margin: -16px 0 0 -16px; content: '\21d4'; color: white; font-weight: bold; font-size: 16px; text-align: center; line-height: 32px; background: #3b82f6; border-radius: 50%; transition: all 0.3s ease; box-shadow: 0 2px 6px rgba(0,0,0,0.3); } .handle:hover:after { transform: scale(1.1); background: #2563eb; } </style> </head> <body class="gradient-bg min-h-screen text-white font-sans"> <div class="container mx-auto px-4 py-8"> <!-- Toast Notification --> <div id="toast" class="toast"> <span id="toast-message"></span> </div> <!-- Header --> <header class="flex justify-between items-center mb-12"> <div class="flex items-center space-x-3"> <div class="w-12 h-12 bg-white rounded-lg flex items-center justify-center shadow-lg"> <i class="fas fa-atom text-3xl text-blue-500"></i> </div> <h1 class="text-3xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-white to-blue-200"> UNO-FLUX <span class="text-sm font-normal opacity-80">Image Processing</span> </h1> </div> <nav class="hidden md:flex space-x-6"> <a href="#" class="hover:text-blue-200 transition">Home</a> <a href="#" class="hover:text-blue-200 transition">Docs</a> <a href="#" class="hover:text-blue-200 transition">Examples</a> <a href="#" class="hover:text-blue-200 transition">Community</a> </nav> <button id="mobile-menu-button" class="md:hidden text-2xl"> <i class="fas fa-bars"></i> </button> </header> <!-- Main Content --> <main class="grid grid-cols-1 lg:grid-cols-3 gap-8"> <!-- Left Panel - Input Section --> <div class="lg:col-span-2 space-y-8"> <div class="bg-white/10 backdrop-blur-md rounded-xl p-6 card-3d wave-pattern"> <h2 class="text-2xl font-semibold mb-4 flex items-center"> <i class="fas fa-sliders-h mr-3 text-blue-300"></i> Image Configuration </h2> <div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div> <label class="block text-sm font-medium mb-2">Model Type</label> <div class="flex space-x-2"> <button id="uno-btn" class="px-4 py-2 bg-blue-600 rounded-lg hover:bg-blue-700 transition flex-1 text-center"> UNO </button> <button id="flux-btn" class="px-4 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition flex-1 text-center"> FLUX </button> </div> </div> <div> <label class="block text-sm font-medium mb-2">Precision</label> <select id="precision-select" class="w-full bg-gray-800 border border-gray-700 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500"> <option>FP32</option> <option selected>FP16</option> <option>INT8</option> </select> </div> <div> <label class="block text-sm font-medium mb-2">Batch Size</label> <input id="batch-slider" type="range" min="1" max="32" value="8" class="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"> <div class="flex justify-between text-xs mt-1"> <span>1</span> <span>8</span> <span>32</span> </div> </div> <div> <label class="block text-sm font-medium mb-2">Learning Rate</label> <div class="relative"> <input id="learning-rate" type="text" value="0.0001" class="w-full bg-gray-800 border border-gray-700 rounded-lg px-4 py-2 pr-10 input-highlight"> <span class="absolute right-3 top-2.5 text-gray-400">LR</span> </div> </div> </div> <div class="mt-6"> <label class="block text-sm font-medium mb-2">Advanced Options</label> <div class="flex flex-wrap gap-2"> <label class="inline-flex items-center"> <input type="checkbox" id="gradient-clipping" class="form-checkbox h-5 w-5 text-blue-600" checked> <span class="ml-2">Gradient Clipping</span> </label> <label class="inline-flex items-center"> <input type="checkbox" id="mixed-precision" class="form-checkbox h-5 w-5 text-blue-600"> <span class="ml-2">Mixed Precision</span> </label> <label class="inline-flex items-center"> <input type="checkbox" id="weight-decay" class="form-checkbox h-5 w-5 text-blue-600" checked> <span class="ml-2">Weight Decay</span> </label> </div> </div> </div> <div class="bg-white/10 backdrop-blur-md rounded-xl p-6 card-3d wave-pattern"> <h2 class="text-2xl font-semibold mb-4 flex items-center"> <i class="fas fa-image mr-3 text-purple-300"></i> Image Input </h2> <div class="mb-4"> <div class="flex border-b border-gray-700"> <button id="upload-tab" class="tab-button px-4 py-2 border-b-2 border-blue-500 active">Upload</button> <button id="camera-tab" class="tab-button px-4 py-2 opacity-70 hover:opacity-100">Camera</button> <button id="url-tab" class="tab-button px-4 py-2 opacity-70 hover:opacity-100">URL</button> </div> </div> <div id="upload-input-container"> <div class="w-full bg-gray-800 border border-gray-700 rounded-lg px-4 py-3 flex flex-col items-center justify-center"> <i class="fas fa-image text-4xl mb-2 opacity-50"></i> <p class="text-gray-400 mb-4">Upload an image file</p> <div class="file-upload"> <button class="px-4 py-2 bg-blue-600 rounded-lg hover:bg-blue-700 transition"> <i class="fas fa-upload mr-2"></i> Select Image </button> <input type="file" id="image-upload" accept="image/*"> </div> <p id="image-filename" class="text-xs mt-2 text-gray-400 hidden"></p> </div> </div> <div id="camera-input-container" class="hidden"> <div class="w-full bg-gray-800 border border-gray-700 rounded-lg px-4 py-3 flex flex-col items-center justify-center"> <i class="fas fa-camera text-4xl mb-2 opacity-50"></i> <p class="text-gray-400 mb-4">Use your camera</p> <button id="start-camera" class="px-4 py-2 bg-blue-600 rounded-lg hover:bg-blue-700 transition"> <i class="fas fa-video mr-2"></i> Start Camera </button> <video id="camera-preview" class="w-full mt-4 hidden" autoplay playsinline></video> <button id="capture-btn" class="px-4 py-2 bg-green-600 rounded-lg hover:bg-green-700 transition mt-4 hidden"> <i class="fas fa-camera mr-2"></i> Capture Image </button> </div> </div> <div id="url-input-container" class="hidden"> <div class="w-full bg-gray-800 border border-gray-700 rounded-lg px-4 py-3 flex flex-col items-center justify-center"> <i class="fas fa-link text-4xl mb-2 opacity-50"></i> <p class="text-gray-400 mb-4">Enter image URL</p> <input type="text" id="image-url" class="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 mb-4" placeholder="https://example.com/image.jpg"> <button id="load-url-btn" class="px-4 py-2 bg-blue-600 rounded-lg hover:bg-blue-700 transition"> <i class="fas fa-download mr-2"></i> Load Image </button> </div> </div> <div class="mt-4"> <h3 class="text-lg font-medium mb-2">Image Preview</h3> <div id="image-preview-container" class="w-full bg-gray-800 border border-gray-700 rounded-lg p-4 flex items-center justify-center min-h-48"> <p class="text-gray-400">No image selected</p> </div> </div> <div class="flex justify-between mt-4"> <div class="flex space-x-2"> <button id="sample-btn" class="px-4 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition"> <i class="fas fa-random mr-2"></i> Sample </button> <button id="reset-btn" class="px-4 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition"> <i class="fas fa-redo mr-2"></i> Reset </button> </div> <button id="run-btn" class="px-6 py-2 bg-blue-600 rounded-lg hover:bg-blue-700 transition font-medium glow-effect"> <i class="fas fa-play mr-2"></i> Process Image </button> </div> </div> </div> <!-- Right Panel - Output Section --> <div class="space-y-8"> <div class="bg-white/10 backdrop-blur-md rounded-xl p-6 card-3d wave-pattern"> <h2 class="text-2xl font-semibold mb-4 flex items-center"> <i class="fas fa-magic mr-3 text-green-300"></i> Image Filters </h2> <div class="grid grid-cols-3 gap-3 mb-4"> <button class="filter-btn px-3 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition" data-filter="none"> <i class="fas fa-ban mr-1"></i> None </button> <button class="filter-btn px-3 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition" data-filter="grayscale"> <i class="fas fa-moon mr-1"></i> Grayscale </button> <button class="filter-btn px-3 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition" data-filter="sepia"> <i class="fas fa-umbrella-beach mr-1"></i> Sepia </button> <button class="filter-btn px-3 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition" data-filter="invert"> <i class="fas fa-adjust mr-1"></i> Invert </button> <button class="filter-btn px-3 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition" data-filter="blur"> <i class="fas fa-blur mr-1"></i> Blur </button> <button class="filter-btn px-3 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition" data-filter="sharpen"> <i class="fas fa-bolt mr-1"></i> Sharpen </button> <button class="filter-btn px-3 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition" data-filter="edge"> <i class="fas fa-border-all mr-1"></i> Edge </button> <button class="filter-btn px-3 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition" data-filter="emboss"> <i class="fas fa-mountain mr-1"></i> Emboss </button> <button class="filter-btn px-3 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition" data-filter="pixelate"> <i class="fas fa-th-large mr-1"></i> Pixelate </button> </div> <div class="mb-4"> <label class="block text-sm font-medium mb-2">Brightness</label> <input type="range" id="brightness-slider" min="0" max="200" value="100" class="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"> </div> <div class="mb-4"> <label class="block text-sm font-medium mb-2">Contrast</label> <input type="range" id="contrast-slider" min="0" max="200" value="100" class="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"> </div> <div class="mb-4"> <label class="block text-sm font-medium mb-2">Saturation</label> <input type="range" id="saturation-slider" min="0" max="200" value="100" class="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"> </div> <div class="flex justify-between"> <button id="apply-filters-btn" class="px-4 py-2 bg-green-600 rounded-lg hover:bg-green-700 transition"> <i class="fas fa-check mr-2"></i> Apply </button> <button id="download-filters-btn" class="px-4 py-2 bg-blue-600 rounded-lg hover:bg-blue-700 transition"> <i class="fas fa-download mr-2"></i> Download </button> </div> </div> <div class="bg-white/10 backdrop-blur-md rounded-xl p-6 card-3d wave-pattern"> <h2 class="text-2xl font-semibold mb-4 flex items-center"> <i class="fas fa-image mr-3 text-yellow-300"></i> Processed Image </h2> <div id="output-container" class="bg-gray-800 rounded-lg p-4 min-h-64 flex items-center justify-center"> <p class="text-gray-400">Processed image will appear here</p> </div> <div class="flex justify-between mt-4"> <button id="compare-btn" class="px-4 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition"> <i class="fas fa-columns mr-2"></i> Compare </button> <button id="download-output-btn" class="px-4 py-2 bg-blue-600 rounded-lg hover:bg-blue-700 transition"> <i class="fas fa-download mr-2"></i> Download </button> </div> </div> <div class="bg-white/10 backdrop-blur-md rounded-xl p-6 card-3d wave-pattern hidden" id="comparison-container"> <h2 class="text-2xl font-semibold mb-4 flex items-center"> <i class="fas fa-columns mr-3 text-purple-300"></i> Before/After Comparison </h2> <div class="ba-slider"> <img id="original-comparison" src="" alt="Original image"> <div class="resize"> <img id="processed-comparison" src="" alt="Processed image"> <div class="handle"></div> </div> </div> <button id="close-comparison" class="w-full mt-4 px-4 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition"> <i class="fas fa-times mr-2"></i> Close Comparison </button> </div> </div> </main> <!-- Footer --> <footer class="mt-12 pt-6 border-t border-white/10"> <div class="flex flex-col md:flex-row justify-between items-center"> <div class="flex items-center space-x-2 mb-4 md:mb-0"> <i class="fas fa-copyright opacity-70"></i> <span class="text-sm opacity-70">2023 bytedance-research</span> </div> <div class="flex space-x-4"> <a href="#" class="opacity-70 hover:opacity-100 transition"> <i class="fab fa-github text-lg"></i> </a> <a href="#" class="opacity-70 hover:opacity-100 transition"> <i class="fab fa-twitter text-lg"></i> </a> <a href="#" class="opacity-70 hover:opacity-100 transition"> <i class="fab fa-discord text-lg"></i> </a> <a href="#" class="opacity-70 hover:opacity-100 transition"> <i class="fab fa-medium text-lg"></i> </a> </div> </div> </footer> </div> <script> document.addEventListener('DOMContentLoaded', function() { // Toast notification function function showToast(message) { const toast = document.getElementById('toast'); const toastMessage = document.getElementById('toast-message'); toastMessage.textContent = message; toast.classList.add('show'); setTimeout(() => { toast.classList.remove('show'); }, 3000); } // Mobile menu toggle const mobileMenuButton = document.getElementById('mobile-menu-button'); mobileMenuButton.addEventListener('click', function() { showToast("Mobile menu would open here"); }); // Model type toggle const unoBtn = document.getElementById('uno-btn'); const fluxBtn = document.getElementById('flux-btn'); unoBtn.addEventListener('click', function() { unoBtn.classList.remove('bg-gray-700', 'hover:bg-gray-600'); unoBtn.classList.add('bg-blue-600', 'hover:bg-blue-700'); fluxBtn.classList.remove('bg-blue-600', 'hover:bg-blue-700'); fluxBtn.classList.add('bg-gray-700', 'hover:bg-gray-600'); showToast("UNO model selected"); }); fluxBtn.addEventListener('click', function() { fluxBtn.classList.remove('bg-gray-700', 'hover:bg-gray-600'); fluxBtn.classList.add('bg-blue-600', 'hover:bg-blue-700'); unoBtn.classList.remove('bg-blue-600', 'hover:bg-blue-700'); unoBtn.classList.add('bg-gray-700', 'hover:bg-gray-600'); showToast("FLUX model selected"); }); // Precision select const precisionSelect = document.getElementById('precision-select'); precisionSelect.addEventListener('change', function() { showToast(`Precision set to ${this.value}`); }); // Batch size slider const batchSlider = document.getElementById('batch-slider'); batchSlider.addEventListener('input', function() { document.getElementById('gpu-usage').textContent = `${Math.min(100, Math.round(78 * (this.value / 8)))}%`; document.getElementById('gpu-bar').style.width = `${Math.min(100, Math.round(78 * (this.value / 8)))}%`; document.getElementById('memory-usage').textContent = `${Math.min(16, (12.4 * (this.value / 8)).toFixed(1))}/16 GB`; document.getElementById('memory-bar').style.width = `${Math.min(100, (77.5 * (this.value / 8)))}%`; document.getElementById('throughput').textContent = `${Math.round(42 * (this.value / 8))} samples/sec`; document.getElementById('throughput-bar').style.width = `${Math.min(100, Math.round(65 * (this.value / 8)))}%`; }); // Learning rate input const learningRateInput = document.getElementById('learning-rate'); learningRateInput.addEventListener('change', function() { if (!this.value.match(/^\d*\.?\d*$/)) { this.value = '0.0001'; showToast("Please enter a valid number for learning rate"); } }); // Advanced options checkboxes document.getElementById('gradient-clipping').addEventListener('change', function() { showToast(`Gradient clipping ${this.checked ? 'enabled' : 'disabled'}`); }); document.getElementById('mixed-precision').addEventListener('change', function() { showToast(`Mixed precision ${this.checked ? 'enabled' : 'disabled'}`); }); document.getElementById('weight-decay').addEventListener('change', function() { showToast(`Weight decay ${this.checked ? 'enabled' : 'disabled'}`); }); // Input tabs const uploadTab = document.getElementById('upload-tab'); const cameraTab = document.getElementById('camera-tab'); const urlTab = document.getElementById('url-tab'); const uploadInputContainer = document.getElementById('upload-input-container'); const cameraInputContainer = document.getElementById('camera-input-container'); const urlInputContainer = document.getElementById('url-input-container'); function activateTab(tab) { // Reset all tabs document.querySelectorAll('.tab-button').forEach(t => { t.classList.remove('active', 'border-b-2', 'border-blue-500'); t.classList.add('opacity-70'); }); // Activate selected tab tab.classList.add('active', 'border-b-2', 'border-blue-500'); tab.classList.remove('opacity-70'); // Show corresponding container uploadInputContainer.classList.add('hidden'); cameraInputContainer.classList.add('hidden'); urlInputContainer.classList.add('hidden'); if (tab === uploadTab) { uploadInputContainer.classList.remove('hidden'); } else if (tab === cameraTab) { cameraInputContainer.classList.remove('hidden'); } else if (tab === urlTab) { urlInputContainer.classList.remove('hidden'); } } uploadTab.addEventListener('click', () => activateTab(uploadTab)); cameraTab.addEventListener('click', () => activateTab(cameraTab)); urlTab.addEventListener('click', () => activateTab(urlTab)); // Image upload handling const imageUpload = document.getElementById('image-upload'); const imageFilename = document.getElementById('image-filename'); const imagePreviewContainer = document.getElementById('image-preview-container'); let originalImage = null; let processedImage = null; imageUpload.addEventListener('change', function() { if (this.files.length > 0) { const file = this.files[0]; imageFilename.textContent = file.name; imageFilename.classList.remove('hidden'); const reader = new FileReader(); reader.onload = function(e) { originalImage = e.target.result; displayImage(originalImage, imagePreviewContainer); showToast("Image loaded successfully"); }; reader.readAsDataURL(file); } }); // Camera functionality const startCameraBtn = document.getElementById('start-camera'); const cameraPreview = document.getElementById('camera-preview'); const captureBtn = document.getElementById('capture-btn'); let stream = null; startCameraBtn.addEventListener('click', async function() { try { stream = await navigator.mediaDevices.getUserMedia({ video: true }); cameraPreview.srcObject = stream; cameraPreview.classList.remove('hidden'); captureBtn.classList.remove('hidden'); startCameraBtn.textContent = 'Camera Active'; startCameraBtn.classList.add('bg-green-600', 'hover:bg-green-700'); showToast("Camera started"); } catch (err) { showToast("Could not access camera: " + err.message); console.error("Camera error:", err); } }); captureBtn.addEventListener('click', function() { const canvas = document.createElement('canvas'); canvas.width = cameraPreview.videoWidth; canvas.height = cameraPreview.videoHeight; const ctx = canvas.getContext('2d'); ctx.drawImage(cameraPreview, 0, 0, canvas.width, canvas.height); originalImage = canvas.toDataURL('image/png'); displayImage(originalImage, imagePreviewContainer); showToast("Image captured"); // Stop camera if (stream) { stream.getTracks().forEach(track => track.stop()); } cameraPreview.srcObject = null; cameraPreview.classList.add('hidden'); captureBtn.classList.add('hidden'); startCameraBtn.textContent = 'Start Camera'; startCameraBtn.classList.remove('bg-green-600', 'hover:bg-green-700'); }); // URL image loading const imageUrlInput = document.getElementById('image-url'); const loadUrlBtn = document.getElementById('load-url-btn'); loadUrlBtn.addEventListener('click', function() { const url = imageUrlInput.value.trim(); if (!url) { showToast("Please enter a valid URL"); return; } // Check if URL is valid try { new URL(url); } catch (e) { showToast("Invalid URL format"); return; } // Create a temporary image to check if it loads const img = new Image(); img.crossOrigin = 'Anonymous'; img.onload = function() { const canvas = document.createElement('canvas'); canvas.width = img.width; canvas.height = img.height; const ctx = canvas.getContext('2d'); ctx.drawImage(img, 0, 0); originalImage = canvas.toDataURL('image/png'); displayImage(originalImage, imagePreviewContainer); showToast("Image loaded from URL"); }; img.onerror = function() { showToast("Could not load image from URL"); }; img.src = url; }); // Sample button document.getElementById('sample-btn').addEventListener('click', function() { const sampleImages = [ 'https://images.unsplash.com/photo-1506744038136-46273834b3fb', 'https://images.unsplash.com/photo-1501785888041-af3ef285b470', 'https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05', 'https://images.unsplash.com/photo-1441974231531-c6227db76b6e', 'https://images.unsplash.com/photo-1429087969512-1e85aab2683d' ]; const randomImageUrl = sampleImages[Math.floor(Math.random() * sampleImages.length)] + '?w=600&h=400&fit=crop'; imageUrlInput.value = randomImageUrl; activateTab(urlTab); // Trigger the URL load setTimeout(() => { loadUrlBtn.click(); }, 100); showToast("Loading sample image..."); }); // Reset button document.getElementById('reset-btn').addEventListener('click', function() { if (originalImage) { displayImage(originalImage, imagePreviewContainer); showToast("Image reset to original"); // Reset filter controls document.querySelectorAll('.filter-btn').forEach(btn => { btn.classList.remove('active'); }); document.getElementById('brightness-slider').value = 100; document.getElementById('contrast-slider').value = 100; document.getElementById('saturation-slider').value = 100; } else { showToast("No image to reset"); } }); // Filter buttons let selectedFilter = 'none'; document.querySelectorAll('.filter-btn').forEach(btn => { btn.addEventListener('click', function() { document.querySelectorAll('.filter-btn').forEach(b => { b.classList.remove('active'); }); this.classList.add('active'); selectedFilter = this.dataset.filter; showToast(`Filter set to: ${this.textContent.trim()}`); }); }); // Apply filters button document.getElementById('apply-filters-btn').addEventListener('click', function() { if (!originalImage) { showToast("Please load an image first"); return; } const brightness = parseInt(document.getElementById('brightness-slider').value); const contrast = parseInt(document.getElementById('contrast-slider').value); const saturation = parseInt(document.getElementById('saturation-slider').value); processImage(originalImage, selectedFilter, brightness, contrast, saturation) .then(processedDataUrl => { processedImage = processedDataUrl; displayImage(processedImage, document.getElementById('output-container')); showToast("Filters applied successfully"); }) .catch(err => { console.error("Image processing error:", err); showToast("Error applying filters"); }); }); // Download buttons document.getElementById('download-filters-btn').addEventListener('click', function() { if (!processedImage) { showToast("No processed image to download"); return; } downloadImage(processedImage, 'filtered-image.png'); }); document.getElementById('download-output-btn').addEventListener('click', function() { if (!processedImage) { showToast("No processed image to download"); return; } downloadImage(processedImage, 'uno-flux-output.png'); }); // Compare button document.getElementById('compare-btn').addEventListener('click', function() { if (!originalImage || !processedImage) { showToast("Please process an image first"); return; } document.getElementById('original-comparison').src = originalImage; document.getElementById('processed-comparison').src = processedImage; document.getElementById('comparison-container').classList.remove('hidden'); // Initialize before/after slider initBeforeAfterSlider(); }); // Close comparison button document.getElementById('close-comparison').addEventListener('click', function() { document.getElementById('comparison-container').classList.add('hidden'); }); // Run model button document.getElementById('run-btn').addEventListener('click', function() { if (!originalImage) { showToast("Please load an image first"); return; } const runButton = this; // Disable button during processing runButton.disabled = true; runButton.classList.add('animate-pulse', 'opacity-75'); // Simulate AI processing setTimeout(() => { // For demo purposes, we'll just apply a random filter const demoFilters = ['edge', 'emboss', 'pixelate', 'invert']; const randomFilter = demoFilters[Math.floor(Math.random() * demoFilters.length)]; processImage(originalImage, randomFilter, 100, 100, 100) .then(processedDataUrl => { processedImage = processedDataUrl; displayImage(processedImage, document.getElementById('output-container')); // Highlight the applied filter document.querySelectorAll('.filter-btn').forEach(btn => { btn.classList.remove('active'); if (btn.dataset.filter === randomFilter) { btn.classList.add('active'); } }); showToast("AI processing complete"); }) .catch(err => { console.error("Image processing error:", err); showToast("Error processing image"); }) .finally(() => { runButton.disabled = false; runButton.classList.remove('animate-pulse', 'opacity-75'); }); }, 2000); }); // Helper function to display an image function displayImage(dataUrl, container) { container.innerHTML = ''; const img = document.createElement('img'); img.src = dataUrl; img.className = 'image-preview'; img.style.display = 'block'; container.appendChild(img); } // Helper function to process an image with filters function processImage(imageData, filter, brightness, contrast, saturation) { return new Promise((resolve, reject) => { const img = new Image(); img.onload = function() { const canvas = document.createElement('canvas'); canvas.width = img.width; canvas.height = img.height; const ctx = canvas.getContext('2d'); // Draw original image ctx.drawImage(img, 0, 0); // Apply brightness, contrast, saturation applyBasicAdjustments(ctx, canvas.width, canvas.height, brightness, contrast, saturation); // Apply selected filter applyFilter(ctx, canvas.width, canvas.height, filter); resolve(canvas.toDataURL('image/png')); }; img.onerror = function() { reject(new Error("Could not load image")); }; img.src = imageData; }); } // Helper function to apply basic image adjustments function applyBasicAdjustments(ctx, width, height, brightness, contrast, saturation) { // Convert brightness from 0-200 to -1 to 1 const brightnessValue = (brightness - 100) / 100; // Convert contrast from 0-200 to -1 to 1 const contrastValue = (contrast - 100) / 100; // Get image data const imageData = ctx.getImageData(0, 0, width, height); const data = imageData.data; // Apply brightness and contrast for (let i = 0; i < data.length; i += 4) { // Brightness data[i] = data[i] + (255 * brightnessValue); data[i+1] = data[i+1] + (255 * brightnessValue); data[i+2] = data[i+2] + (255 * brightnessValue); // Contrast const factor = (259 * (contrastValue + 255)) / (255 * (259 - contrastValue)); data[i] = factor * (data[i] - 128) + 128; data[i+1] = factor * (data[i+1] - 128) + 128; data[i+2] = factor * (data[i+2] - 128) + 128; } // Apply saturation if needed if (saturation !== 100) { const saturationValue = saturation / 100; for (let i = 0; i < data.length; i += 4) { const r = data[i]; const g = data[i+1]; const b = data[i+2]; // Convert to grayscale const gray = 0.299 * r + 0.587 * g + 0.114 * b; // Apply saturation data[i] = gray + (r - gray) * saturationValue; data[i+1] = gray + (g - gray) * saturationValue; data[i+2] = gray + (b - gray) * saturationValue; } } ctx.putImageData(imageData, 0, 0); } // Helper function to apply various filters function applyFilter(ctx, width, height, filter) { if (filter === 'none') return; const imageData = ctx.getImageData(0, 0, width, height); const data = imageData.data; switch(filter) { case 'grayscale': for (let i = 0; i < data.length; i += 4) { const avg = 0.299 * data[i] + 0.587 * data[i+1] + 0.114 * data[i+2]; data[i] = avg; data[i+1] = avg; data[i+2] = avg; } break; case 'sepia': for (let i = 0; i < data.length; i += 4) { const r = data[i]; const g = data[i+1]; const b = data[i+2]; data[i] = Math.min(255, (r * 0.393) + (g * 0.769) + (b * 0.189)); data[i+1] = Math.min(255, (r * 0.349) + (g * 0.686) + (b * 0.168)); data[i+2] = Math.min(255, (r * 0.272) + (g * 0.534) + (b * 0.131)); } break; case 'invert': for (let i = 0; i < data.length; i += 4) { data[i] = 255 - data[i]; data[i+1] = 255 - data[i+1]; data[i+2] = 255 - data[i+2]; } break; case 'blur': // Simple box blur const tempCanvas = document.createElement('canvas'); tempCanvas.width = width; tempCanvas.height = height; const tempCtx = tempCanvas.getContext('2d'); tempCtx.putImageData(imageData, 0, 0); // Apply blur multiple times for stronger effect for (let i = 0; i < 3; i++) { const blurData = tempCtx.getImageData(0, 0, width, height); const blurPixels = blurData.data; for (let y = 1; y < height-1; y++) { for (let x = 1; x < width-1; x++) { const idx = (y * width + x) * 4; // Average surrounding pixels let r = 0, g = 0, b = 0; for (let dy = -1; dy <= 1; dy++) { for (let dx = -1; dx <= 1; dx++) { const sidx = ((y+dy) * width + (x+dx)) * 4; r += blurPixels[sidx]; g += blurPixels[sidx+1]; b += blurPixels[sidx+2]; } } data[idx] = r / 9; data[idx+1] = g / 9; data[idx+2] = b / 9; } } tempCtx.putImageData(imageData, 0, 0); } break; case 'sharpen': // Simple sharpen kernel const sharpenKernel = [ [ 0, -1, 0], [-1, 5, -1], [ 0, -1, 0] ]; applyConvolutionFilter(data, width, height, sharpenKernel); break; case 'edge': // Edge detection kernel const edgeKernel = [ [-1, -1, -1], [-1, 8, -1], [-1, -1, -1] ]; applyConvolutionFilter(data, width, height, edgeKernel); break; case 'emboss': // Emboss kernel const embossKernel = [ [-2, -1, 0], [-1, 1, 1], [ 0, 1, 2] ]; applyConvolutionFilter(data, width, height, embossKernel); // Add some brightness for (let i = 0; i < data.length; i += 4) { data[i] = Math.min(255, data[i] + 50); data[i+1] = Math.min(255, data[i+1] + 50); data[i+2] = Math.min(255, data[i+2] + 50); } break; case 'pixelate': const pixelSize = 10; for (let y = 0; y < height; y += pixelSize) { for (let x = 0; x < width; x += pixelSize) { // Get the average color of the block let r = 0, g = 0, b = 0, count = 0; for (let dy = 0; dy < pixelSize && y + dy < height; dy++) { for (let dx = 0; dx < pixelSize && x + dx < width; dx++) { const idx = ((y + dy) * width + (x + dx)) * 4; r += data[idx]; g += data[idx+1]; b += data[idx+2]; count++; } } r = Math.round(r / count); g = Math.round(g / count); b = Math.round(b / count); // Fill the block with the average color for (let dy = 0; dy < pixelSize && y + dy < height; dy++) { for (let dx = 0; dx < pixelSize && x + dx < width; dx++) { const idx = ((y + dy) * width + (x + dx)) * 4; data[idx] = r; data[idx+1] = g; data[idx+2] = b; } } } } break; } ctx.putImageData(imageData, 0, 0); } // Helper function to apply convolution filter function applyConvolutionFilter(data, width, height, kernel) { const tempData = new Uint8ClampedArray(data.length); for (let y = 1; y < height-1; y++) { for (let x = 1; x < width-1; x++) { const idx = (y * width + x) * 4; let r = 0, g = 0, b = 0; for (let ky = -1; ky <= 1; ky++) { for (let kx = -1; kx <= 1; kx++) { const kidx = ((y + ky) * width + (x + kx)) * 4; const kvalue = kernel[ky+1][kx+1]; r += data[kidx] * kvalue; g += data[kidx+1] * kvalue; b += data[kidx+2] * kvalue; } } // Clamp values to 0-255 tempData[idx] = Math.max(0, Math.min(255, r)); tempData[idx+1] = Math.max(0, Math.min(255, g)); tempData[idx+2] = Math.max(0, Math.min(255, b)); tempData[idx+3] = data[idx+3]; // Alpha channel } } // Copy back to original data for (let i = 0; i < data.length; i++) { data[i] = tempData[i]; } } // Helper function to download an image function downloadImage(dataUrl, filename) { const a = document.createElement('a'); a.href = dataUrl; a.download = filename; document.body.appendChild(a); a.click(); document.body.removeChild(a); showToast("Image downloaded"); } // Initialize before/after slider function initBeforeAfterSlider() { const slider = document.querySelector('.ba-slider'); const resize = slider.querySelector('.resize'); const handle = slider.querySelector('.handle'); let isDragging = false; function moveDivider(clientX) { const rect = slider.getBoundingClientRect(); let newWidth = clientX - rect.left; // Constrain between 0 and slider width newWidth = Math.max(0, Math.min(newWidth, rect.width)); resize.style.width = newWidth + 'px'; handle.style.left = newWidth + 'px'; } handle.addEventListener('mousedown', function(e) { isDragging = true; e.preventDefault(); }); document.addEventListener('mousemove', function(e) { if (!isDragging) return; moveDivider(e.clientX); }); document.addEventListener('mouseup', function() { isDragging = false; }); // Touch support handle.addEventListener('touchstart', function(e) { isDragging = true; e.preventDefault(); }); document.addEventListener('touchmove', function(e) { if (!isDragging) return; moveDivider(e.touches[0].clientX); }); document.addEventListener('touchend', function() { isDragging = false; }); } }); </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=MarcRyan/image-configuration" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> </html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UNO-FLUX Image Processing Dashboard</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>
@keyframes gradientFlow {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
.gradient-bg {
background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
background-size: 400% 400%;
animation: gradientFlow 15s ease infinite;
}
.card-3d {
transform-style: preserve-3d;
transition: all 0.5s ease;
}
.card-3d:hover {
transform: rotateY(10deg) rotateX(5deg) translateY(-5px);
box-shadow: 0 20px 30px rgba(0,0,0,0.2);
}
.glow-effect {
box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}
.input-highlight {
transition: all 0.3s ease;
border-bottom: 2px solid transparent;
}
.input-highlight:focus {
border-bottom: 2px solid #3b82f6;
box-shadow: none;
}
.wave-pattern {
background-image: radial-gradient(circle at 10% 20%, rgba(255,255,255,0.1) 0%, transparent 20%);
}
/* Custom file upload button */
.file-upload {
position: relative;
overflow: hidden;
display: inline-block;
}
.file-upload input[type="file"] {
position: absolute;
left: 0;
top: 0;
opacity: 0;
width: 100%;
height: 100%;
cursor: pointer;
}
/* Tab styling */
.tab-button.active {
border-bottom: 2px solid #3b82f6;
opacity: 1;
}
/* Toast notification */
.toast {
position: fixed;
bottom: 20px;
right: 20px;
background: rgba(0,0,0,0.8);
color: white;
padding: 12px 24px;
border-radius: 8px;
transform: translateY(100px);
opacity: 0;
transition: all 0.3s ease;
z-index: 1000;
}
.toast.show {
transform: translateY(0);
opacity: 1;
}
/* Image preview */
.image-preview {
max-width: 100%;
max-height: 300px;
object-fit: contain;
border-radius: 8px;
display: none;
}