Spaces:
Sleeping
Sleeping
Download frontend/index.html from abdurrehmansaeed/ThreadNode: direct link, hf CLI and curl.
- Browser
- Download file 12.9 kB
-
https://huggingface.co/spaces/abdurrehmansaeed/ThreadNode/resolve/main/frontend/index.html
- Command line
-
hf download hf://spaces/abdurrehmansaeed/ThreadNode/frontend/index.html
-
curl -L -o index.html https://huggingface.co/spaces/abdurrehmansaeed/ThreadNode/resolve/main/frontend/index.html
12.9 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>ThreadNode</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <style> | |
| /* Playful Floating Animations */ | |
| @keyframes float { | |
| 0% { transform: translateY(0px); } | |
| 50% { transform: translateY(-10px); } | |
| 100% { transform: translateY(0px); } | |
| } | |
| .animate-float { | |
| animation: float 6s ease-in-out infinite; | |
| } | |
| .animate-in { animation: animate-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); } | |
| .fade-in { opacity: 0; animation-fill-mode: forwards; } | |
| @keyframes animate-in { | |
| from { opacity: 0; transform: scale(0.95) translateY(10px); } | |
| to { opacity: 1; transform: scale(1) translateY(0); } | |
| } | |
| /* Custom scrollbar for dark mode */ | |
| ::-webkit-scrollbar { width: 8px; } | |
| ::-webkit-scrollbar-track { background: transparent; } | |
| ::-webkit-scrollbar-thumb { background: #4c1d95; border-radius: 10px; } | |
| </style> | |
| </head> | |
| <body class="min-h-screen bg-slate-950 text-slate-200 font-sans flex flex-col items-center justify-center p-6 relative overflow-hidden selection:bg-fuchsia-500/30"> | |
| <div class="absolute top-[-10%] left-[-10%] w-[500px] h-[500px] bg-violet-600/20 rounded-full mix-blend-screen filter blur-[120px] animate-float" style="animation-delay: 0s;"></div> | |
| <div class="absolute bottom-[-10%] right-[-10%] w-[500px] h-[500px] bg-fuchsia-600/20 rounded-full mix-blend-screen filter blur-[120px] animate-float" style="animation-delay: 3s;"></div> | |
| <div class="max-w-4xl w-full mb-8 relative z-10 text-center md:text-left"> | |
| <h1 class="text-4xl font-extrabold tracking-tight text-white mb-1"> | |
| Thread<span class="text-transparent bg-clip-text bg-gradient-to-r from-violet-400 to-fuchsia-400">Node</span> | |
| </h1> | |
| <p class="text-slate-400 font-medium text-sm">Visual Inference Engine</p> | |
| </div> | |
| <div class="max-w-4xl w-full grid grid-cols-1 md:grid-cols-2 gap-8 relative z-10"> | |
| <div id="drop-zone" class="bg-slate-900 rounded-[2rem] shadow-2xl shadow-violet-900/10 border border-slate-800 p-8 transition-all duration-300 min-h-[420px] flex flex-col items-center justify-center relative hover:shadow-violet-500/10 hover:border-violet-500/30 hover:-translate-y-1"> | |
| <div id="upload-prompt" class="text-center w-full cursor-pointer group" onclick="document.getElementById('file-input').click()"> | |
| <input type="file" id="file-input" accept="image/*" class="hidden" /> | |
| <div class="w-16 h-16 rounded-full bg-slate-800 text-violet-400 flex items-center justify-center mx-auto mb-4 group-hover:bg-slate-700 group-hover:scale-110 transition-all duration-300 shadow-sm border border-slate-700 group-hover:border-violet-500/50"> | |
| <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"></path></svg> | |
| </div> | |
| <p class="text-slate-300 font-semibold mb-1">Upload Target Image</p> | |
| <p class="text-slate-500 text-sm">Drag & drop or browse</p> | |
| </div> | |
| <div id="preview-container" class="hidden relative w-full h-full flex flex-col items-center justify-between"> | |
| <div class="flex-1 flex items-center justify-center mb-6 w-full relative"> | |
| <img id="image-preview" class="max-h-[280px] object-contain rounded-2xl shadow-xl border border-slate-700 bg-slate-800/50 p-1" /> | |
| </div> | |
| <button id="execute-btn" class="w-full py-4 px-6 bg-gradient-to-r from-violet-600 to-fuchsia-600 text-white font-bold rounded-full hover:shadow-[0_0_20px_rgba(217,70,239,0.4)] hover:-translate-y-0.5 active:translate-y-0 transition-all duration-200 text-lg"> | |
| Classify Image | |
| </button> | |
| </div> | |
| </div> | |
| <div class="flex flex-col bg-slate-900 rounded-[2rem] shadow-2xl shadow-violet-900/10 border border-slate-800 p-8 min-h-[420px]"> | |
| <div class="flex items-center gap-3 mb-6 pb-4 border-b border-slate-800"> | |
| <div class="p-2 bg-fuchsia-500/10 rounded-xl text-fuchsia-400 border border-fuchsia-500/20"> | |
| <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"></path></svg> | |
| </div> | |
| <h2 class="text-sm font-bold tracking-widest text-slate-300 uppercase"> | |
| Telemetry Stream | |
| </h2> | |
| </div> | |
| <div id="error-message" class="hidden bg-rose-950/50 text-rose-400 border border-rose-900/50 p-4 rounded-2xl text-sm mb-4 font-medium"></div> | |
| <div id="idle-state" class="flex-1 flex flex-col items-center justify-center text-slate-600 text-sm font-medium"> | |
| <svg class="w-12 h-12 text-slate-700 mb-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"></path></svg> | |
| Awaiting Payload... | |
| </div> | |
| <div id="loading-state" class="hidden flex-1 flex flex-col items-center justify-center space-y-4"> | |
| <div class="flex gap-2"> | |
| <div class="w-3 h-3 bg-violet-500 rounded-full animate-bounce shadow-[0_0_10px_rgba(139,92,246,0.8)]" style="animation-delay: 0s"></div> | |
| <div class="w-3 h-3 bg-fuchsia-500 rounded-full animate-bounce shadow-[0_0_10px_rgba(217,70,239,0.8)]" style="animation-delay: 0.1s"></div> | |
| <div class="w-3 h-3 bg-pink-500 rounded-full animate-bounce shadow-[0_0_10px_rgba(236,72,153,0.8)]" style="animation-delay: 0.2s"></div> | |
| </div> | |
| <p class="text-slate-400 font-medium text-sm animate-pulse">Analyzing visual features...</p> | |
| </div> | |
| <div id="results-state" class="hidden flex-1 flex flex-col space-y-8 animate-in fade-in"> | |
| <div class="flex-1 flex flex-col justify-center"> | |
| <p class="text-xs text-slate-500 font-bold uppercase tracking-widest mb-4">Extracted Taxonomy</p> | |
| <div id="tags-container" class="flex flex-wrap items-center gap-2.5"> | |
| </div> | |
| </div> | |
| <div class="pt-6 border-t border-slate-800 bg-slate-950/50 -mx-8 -mb-8 p-8 rounded-b-[2rem] flex justify-end items-center"> | |
| <div class="text-right"> | |
| <p class="text-[10px] text-slate-500 font-bold uppercase tracking-widest mb-1">Status</p> | |
| <p class="font-bold text-sm uppercase flex items-center gap-2 justify-end text-slate-200"> | |
| <span class="w-2.5 h-2.5 rounded-full bg-emerald-400 shadow-[0_0_12px_rgba(52,211,153,0.6)]"></span> | |
| <span id="status-text"></span> | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| const dropZone = document.getElementById('drop-zone'); | |
| const fileInput = document.getElementById('file-input'); | |
| const uploadPrompt = document.getElementById('upload-prompt'); | |
| const previewContainer = document.getElementById('preview-container'); | |
| const imagePreview = document.getElementById('image-preview'); | |
| const executeBtn = document.getElementById('execute-btn'); | |
| const idleState = document.getElementById('idle-state'); | |
| const loadingState = document.getElementById('loading-state'); | |
| const resultsState = document.getElementById('results-state'); | |
| const errorMessage = document.getElementById('error-message'); | |
| const tagsContainer = document.getElementById('tags-container'); | |
| let selectedFile = null; | |
| function resetUI() { | |
| idleState.classList.add('hidden'); | |
| loadingState.classList.add('hidden'); | |
| resultsState.classList.add('hidden'); | |
| errorMessage.classList.add('hidden'); | |
| } | |
| function handleFile(file) { | |
| if (!file || !file.type.startsWith('image/')) { | |
| resetUI(); | |
| errorMessage.textContent = 'Oops! Please upload an image file.'; | |
| errorMessage.classList.remove('hidden'); | |
| return; | |
| } | |
| selectedFile = file; | |
| const reader = new FileReader(); | |
| reader.onload = (e) => { | |
| imagePreview.src = e.target.result; | |
| uploadPrompt.classList.add('hidden'); | |
| previewContainer.classList.remove('hidden'); | |
| resetUI(); | |
| idleState.classList.remove('hidden'); | |
| }; | |
| reader.readAsDataURL(file); | |
| } | |
| fileInput.addEventListener('change', (e) => handleFile(e.target.files[0])); | |
| dropZone.addEventListener('dragover', (e) => { | |
| e.preventDefault(); | |
| dropZone.classList.add('border-violet-500/50', 'bg-slate-800'); | |
| }); | |
| dropZone.addEventListener('dragleave', () => { | |
| dropZone.classList.remove('border-violet-500/50', 'bg-slate-800'); | |
| }); | |
| dropZone.addEventListener('drop', (e) => { | |
| e.preventDefault(); | |
| dropZone.classList.remove('border-violet-500/50', 'bg-slate-800'); | |
| handleFile(e.dataTransfer.files[0]); | |
| }); | |
| executeBtn.addEventListener('click', async () => { | |
| if (!selectedFile) return; | |
| resetUI(); | |
| loadingState.classList.remove('hidden'); | |
| executeBtn.disabled = true; | |
| executeBtn.textContent = 'Analyzing...'; | |
| executeBtn.classList.add('opacity-70', 'cursor-not-allowed', 'scale-[0.98]'); | |
| const formData = new FormData(); | |
| formData.append('file', selectedFile); | |
| try { | |
| const response = await fetch('/predict', { | |
| method: 'POST', | |
| body: formData | |
| }); | |
| if (!response.ok) throw new Error('Could not connect to the inference engine.'); | |
| const data = await response.json(); | |
| tagsContainer.innerHTML = ''; | |
| if (data.tags.length > 0) { | |
| data.tags.forEach((tag, index) => { | |
| // Updated Tags for dark mode: glowing borders, deep violet backgrounds | |
| const tagHTML = `<span class="px-5 py-2.5 bg-violet-500/10 text-violet-300 rounded-full text-sm font-extrabold tracking-wide border border-violet-500/20 hover:bg-violet-500/20 hover:border-violet-400/50 hover:shadow-[0_0_15px_rgba(139,92,246,0.2)] hover:scale-105 transition-all cursor-default backdrop-blur-sm">${tag}</span>`; | |
| tagsContainer.innerHTML += tagHTML; | |
| if (index < data.tags.length - 1) { | |
| tagsContainer.innerHTML += `<svg class="w-5 h-5 text-fuchsia-400/60 stroke-[3px]" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7"></path></svg>`; | |
| } | |
| }); | |
| } else { | |
| tagsContainer.innerHTML = '<span class="text-slate-500 font-medium bg-slate-800 px-4 py-2 rounded-full text-sm border border-slate-700">No classes detected.</span>'; | |
| } | |
| document.getElementById('status-text').textContent = data.status; | |
| loadingState.classList.add('hidden'); | |
| resultsState.classList.remove('hidden'); | |
| } catch (err) { | |
| loadingState.classList.add('hidden'); | |
| errorMessage.textContent = err.message; | |
| errorMessage.classList.remove('hidden'); | |
| } finally { | |
| executeBtn.disabled = false; | |
| executeBtn.textContent = 'Classify Image'; | |
| executeBtn.classList.remove('opacity-70', 'cursor-not-allowed', 'scale-[0.98]'); | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> |