Spaces:
Running
Running
Download index.html from codrizsain/zero-team2: direct link, hf CLI and curl.
- Browser
- Download file 20.5 kB
-
https://huggingface.co/spaces/codrizsain/zero-team2/resolve/ba76729b58e0a170f973b2bd9a3c6ba30a92d4f2/index.html
- Command line
-
hf download hf://spaces/codrizsain/zero-team2@ba76729b58e0a170f973b2bd9a3c6ba30a92d4f2/index.html
-
curl -L -o index.html https://huggingface.co/spaces/codrizsain/zero-team2/resolve/ba76729b58e0a170f973b2bd9a3c6ba30a92d4f2/index.html
20.5 kB
| <html lang="id"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Zero-Team AI - Biometric Dashboard v23</title> | |
| <!-- Library AI MediaPipe --> | |
| <script src="https://cdn.jsdelivr.net/npm/@mediapipe/camera_utils/camera_utils.js" crossorigin="anonymous"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/@mediapipe/drawing_utils/drawing_utils.js" crossorigin="anonymous"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands.js" crossorigin="anonymous"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/face_mesh.js" crossorigin="anonymous"></script> | |
| <style> | |
| body { | |
| background: radial-gradient(circle at top, #1e293b, #0f172a); | |
| color: #f8fafc; | |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| display: flex; flex-direction: column; align-items: center; | |
| margin: 0; padding: 20px; min-height: 100vh; overflow-x: hidden; | |
| } | |
| #startBtn { | |
| background: linear-gradient(135deg, #a855f7, #ec4899); | |
| color: white; border: none; padding: 15px 40px; | |
| font-size: 18px; border-radius: 50px; cursor: pointer; | |
| font-weight: bold; box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4); | |
| transition: all 0.3s ease; margin-bottom: 20px; | |
| text-transform: uppercase; letter-spacing: 1px; | |
| } | |
| #startBtn:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(236, 72, 153, 0.6); } | |
| #mainStatus { | |
| font-size: 20px; font-weight: bold; color: #94a3b8; | |
| background: rgba(15, 23, 42, 0.6); padding: 10px 30px; | |
| border-radius: 12px; border: 1px solid #334155; margin-bottom: 25px; | |
| text-align: center; | |
| } | |
| /* --- LAYOUT UTAMA --- */ | |
| .dashboard-container { | |
| display: flex; flex-direction: row; gap: 25px; | |
| align-items: flex-start; justify-content: center; | |
| width: 100%; max-width: 1300px; | |
| } | |
| /* PANEL KIRI & KANAN */ | |
| .side-panel { | |
| background: rgba(15, 23, 42, 0.7); | |
| border: 2px solid #3b82f6; border-radius: 12px; | |
| padding: 20px; width: 260px; | |
| box-shadow: 0 0 20px rgba(59, 130, 246, 0.3); | |
| backdrop-filter: blur(10px); | |
| display: flex; flex-direction: column; gap: 15px; | |
| } | |
| .side-panel.pink-border { border-color: #ec4899; box-shadow: 0 0 20px rgba(236, 72, 153, 0.3); } | |
| .panel-title { font-size: 12px; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid #334155; padding-bottom: 8px; margin-bottom: 5px; } | |
| .data-item { display: flex; flex-direction: column; gap: 4px; } | |
| .data-label { font-size: 14px; font-weight: bold; color: #f8fafc; } | |
| .data-value { font-size: 13px; color: #10b981; } | |
| /* MONITOR TENGAH */ | |
| .center-stage { display: flex; flex-direction: column; align-items: center; gap: 20px; } | |
| .canvas-container { position: relative; } | |
| canvas { | |
| border: 3px solid #06b6d4; box-shadow: 0 0 25px rgba(6, 182, 212, 0.4); | |
| border-radius: 16px; background-color: #000; | |
| width: 640px; height: 480px; object-fit: cover; | |
| transform: scaleX(-1); | |
| } | |
| .pose1-anim { | |
| position: absolute; opacity: 0; border-radius: 8px; z-index: 10; | |
| border: 2px solid #eab308; box-shadow: 0 0 15px rgba(234, 179, 8, 0.8); | |
| pointer-events: none; transition: opacity 0.2s, left 0.1s, top 0.1s; | |
| transform: scaleX(-1); | |
| } | |
| /* --- INDIKATOR POSE --- */ | |
| .pose-indicators { display: flex; gap: 15px; justify-content: center; width: 100%; } | |
| .pose-box { | |
| background: rgba(15, 23, 42, 0.5); border: 1px solid #334155; | |
| border-radius: 12px; padding: 15px 10px; text-align: center; | |
| width: 85px; display: flex; flex-direction: column; align-items: center; justify-content: center; | |
| transition: all 0.2s ease; opacity: 0.6; | |
| } | |
| .pose-emoji { font-size: 26px; margin-bottom: 8px; } | |
| .pose-name { font-size: 12px; font-weight: bold; color: #64748b; transition: color 0.2s; } | |
| .pose-box.active { | |
| border: 2px solid #eab308; background: rgba(234, 179, 8, 0.1); | |
| box-shadow: 0 0 15px rgba(234, 179, 8, 0.5); opacity: 1; transform: scale(1.05); | |
| } | |
| .pose-box.active .pose-name { color: #f8fafc; } | |
| </style> | |
| </head> | |
| <body> | |
| <button id="startBtn">▶ Mulai Sistem Deteksi</button> | |
| <div id="mainStatus">Sistem Menunggu Kamera...</div> | |
| <div class="dashboard-container"> | |
| <!-- PANEL KIRI (Sistem) --> | |
| <div class="side-panel"> | |
| <div class="data-item" style="margin-bottom: 10px;"> | |
| <div class="data-label" style="font-size: 18px; color: #38bdf8;">⚙️ Zero-Team AI</div> | |
| </div> | |
| <div class="data-item"><div class="data-label">👁️ Computer Vision Engine</div></div> | |
| <div class="data-item"><div class="data-label">🖐️ Mediapipe Hands: v0.10.x</div></div> | |
| <div class="data-item"><div class="data-label">🎭 Mediapipe FaceMesh: v0.10.x</div></div> | |
| <div class="data-item" style="margin-top: 20px;"> | |
| <div class="data-label">🛡️ Status Deteksi:</div> | |
| <div id="statusKiri" class="data-value" style="color: #94a3b8; font-size: 14px;">Standby</div> | |
| </div> | |
| </div> | |
| <!-- TENGAH (Kamera & Indikator Pose) --> | |
| <div class="center-stage"> | |
| <div class="canvas-container"> | |
| <!-- Video disembunyikan, dirender ke canvas --> | |
| <video id="videoElement" style="display: none;" autoplay playsinline></video> | |
| <canvas id="outputCanvas" width="640" height="480"></canvas> | |
| <img id="pose1Anim1" class="pose1-anim" src="animasi1.gif" alt="Pose 1"> | |
| <img id="pose1Anim2" class="pose1-anim" src="animasi1.gif" alt="Pose 2"> | |
| </div> | |
| <div class="pose-indicators"> | |
| <div id="boxPose1" class="pose-box"><div class="pose-emoji">👍</div><div class="pose-name">Thumbs Up</div></div> | |
| <div id="boxPose2" class="pose-box"><div class="pose-emoji">✌️</div><div class="pose-name">Peace</div></div> | |
| <div id="boxPose3" class="pose-box"><div class="pose-emoji">👌</div><div class="pose-name">Okay</div></div> | |
| <div id="boxPose4" class="pose-box"><div class="pose-emoji">🖐️</div><div class="pose-name">Open Palm</div></div> | |
| <div id="boxPose5" class="pose-box"><div class="pose-emoji">✊</div><div class="pose-name">Fist</div></div> | |
| </div> | |
| </div> | |
| <!-- PANEL KANAN (Biometrik Wajah) --> | |
| <div style="display: flex; flex-direction: column; gap: 20px;"> | |
| <div class="side-panel"> | |
| <div class="panel-title">Kondisi Biometrik (Wajah)</div> | |
| <div class="data-item"> | |
| <div class="data-label">Bentuk Wajah</div> | |
| <div id="valWajah" class="data-value" style="color: #cbd5e1;">Memindai...</div> | |
| </div> | |
| <div class="data-item"> | |
| <div class="data-label">Bentuk Rahang</div> | |
| <div id="valRahang" class="data-value" style="color: #cbd5e1;">Memindai...</div> | |
| </div> | |
| <div class="data-item"> | |
| <div class="data-label">Karakter Alis</div> | |
| <div id="valAlis" class="data-value" style="color: #cbd5e1;">Memindai...</div> | |
| </div> | |
| </div> | |
| <div class="side-panel pink-border"> | |
| <div class="data-item"> | |
| <div class="panel-title">Kondisi Mood</div> | |
| <div id="moodValue" class="data-label" style="font-size: 18px;">Menganalisis...</div> | |
| </div> | |
| <div class="data-item" style="margin-top: 10px;"> | |
| <div class="panel-title">Estimasi Gender / Hijab</div> | |
| <div id="genderValue" class="data-label" style="font-size: 18px;">Memindai...</div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <audio id="audio1" src="suara1.mp3"></audio> | |
| <audio id="audio2" src="suara2.mp3"></audio> | |
| <audio id="audio3" src="suara3.mp3"></audio> | |
| <audio id="audio4" src="suara4.mp3"></audio> | |
| <audio id="audio5" src="suara5.mp3"></audio> | |
| <script> | |
| const videoElement = document.getElementById('videoElement'); | |
| const canvasElement = document.getElementById('outputCanvas'); | |
| const canvasCtx = canvasElement.getContext('2d'); | |
| const startBtn = document.getElementById('startBtn'); | |
| const mainStatus = document.getElementById('mainStatus'); | |
| const statusKiri = document.getElementById('statusKiri'); | |
| const valWajah = document.getElementById('valWajah'); | |
| const valRahang = document.getElementById('valRahang'); | |
| const valAlis = document.getElementById('valAlis'); | |
| const moodValue = document.getElementById('moodValue'); | |
| const genderValue = document.getElementById('genderValue'); | |
| const anims = [document.getElementById('pose1Anim1'), document.getElementById('pose1Anim2')]; | |
| const sounds = [ | |
| document.getElementById('audio1'), document.getElementById('audio2'), | |
| document.getElementById('audio3'), document.getElementById('audio4'), | |
| document.getElementById('audio5') | |
| ]; | |
| const poseBoxes = [ | |
| document.getElementById('boxPose1'), document.getElementById('boxPose2'), | |
| document.getElementById('boxPose3'), document.getElementById('boxPose4'), | |
| document.getElementById('boxPose5') | |
| ]; | |
| let memoryActivePoses = []; | |
| let memoryTimer = 0; | |
| let currentFaceLandmarks = null; | |
| function getDistance(p1, p2) { return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)); } | |
| // --- ALGORITMA BIOMETRIK & HIJAB --- | |
| function analyzeFaceBiometrics(faceLandmarks) { | |
| const dahi = faceLandmarks[10]; const dagu = faceLandmarks[152]; | |
| const pipiKiri = faceLandmarks[234]; const pipiKanan = faceLandmarks[454]; | |
| const rahangKiri = faceLandmarks[132]; const rahangKanan = faceLandmarks[361]; | |
| const alisKiri = faceLandmarks[159]; const alisKiriTengah = faceLandmarks[52]; | |
| const faceHeight = getDistance(dahi, dagu); | |
| const faceWidth = getDistance(pipiKiri, pipiKanan); | |
| const jawWidth = getDistance(rahangKiri, rahangKanan); | |
| const ratioFace = faceHeight / faceWidth; | |
| let faceText = "Bulat / Pendek"; | |
| if (ratioFace > 1.35) faceText = "Oval / Heart"; | |
| else if (ratioFace > 1.20) faceText = "Kotak / Simetris"; | |
| const ratioJaw = jawWidth / faceWidth; | |
| let jawText = "Tirus / V-Shape"; | |
| if (ratioJaw > 0.85) jawText = "Square-Strong"; | |
| else if (ratioJaw > 0.75) jawText = "Tapered / Normal"; | |
| const ratioEyebrow = getDistance(alisKiri, alisKiriTengah) / faceHeight; | |
| let browText = "Datar / Straight"; | |
| if (ratioEyebrow > 0.055) browText = "Arched-High"; | |
| else if (ratioEyebrow > 0.040) browText = "Melengkung Alami"; | |
| const mouthWidth = getDistance(faceLandmarks[61], faceLandmarks[291]); | |
| const mouthHeight = getDistance(faceLandmarks[13], faceLandmarks[14]); | |
| let moodText = "Netral 😐"; let moodColor = "#3b82f6"; | |
| if (mouthHeight / faceWidth > 0.15) { moodText = "Terkejut 😲"; moodColor = "#a855f7"; } | |
| else if (mouthWidth / faceWidth > 0.52) { moodText = "Senang 😊"; moodColor = "#10b981"; } | |
| const headRatio = getDistance(dahi, faceLandmarks[168]) / jawWidth; | |
| let genderText = "Pria 👨"; let genderColor = "#60a5fa"; | |
| if (headRatio < 0.22 || ratioJaw < 0.75) { | |
| genderText = "Wanita 👩 (Hijab/Tirus)"; genderColor = "#f472b6"; | |
| } | |
| return { faceText, jawText, browText, moodText, moodColor, genderText, genderColor }; | |
| } | |
| // --- ALGORITMA POSE --- | |
| function classifyPose(landmarks) { | |
| const indexOpen = landmarks[8].y < landmarks[6].y; | |
| const middleOpen = landmarks[12].y < landmarks[10].y; | |
| const ringOpen = landmarks[16].y < landmarks[14].y; | |
| const pinkyOpen = landmarks[20].y < landmarks[18].y; | |
| const thumbOpen = getDistance(landmarks[4], landmarks[5]) > 0.08; | |
| if (!indexOpen && !middleOpen && !ringOpen && !pinkyOpen) return { id: 5, name: "Fist" }; | |
| if (indexOpen && middleOpen && ringOpen && pinkyOpen && thumbOpen) return { id: 4, name: "Open Palm" }; | |
| if (indexOpen && middleOpen && !ringOpen && !pinkyOpen) return { id: 2, name: "Peace" }; | |
| if (thumbOpen && indexOpen && !middleOpen && !ringOpen && !pinkyOpen) return { id: 1, name: "Thumbs Up" }; | |
| if (getDistance(landmarks[4], landmarks[8]) < 0.05 && middleOpen && ringOpen && pinkyOpen) return { id: 3, name: "Okay" }; | |
| return null; | |
| } | |
| // SETUP AI (Ringan & Cepat) | |
| const faceMesh = new FaceMesh({locateFile: (file) => `https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/${file}`}); | |
| faceMesh.setOptions({ maxNumFaces: 1, refineLandmarks: false, minDetectionConfidence: 0.5, minTrackingConfidence: 0.5 }); | |
| faceMesh.onResults((results) => { currentFaceLandmarks = (results.multiFaceLandmarks && results.multiFaceLandmarks.length > 0) ? results.multiFaceLandmarks[0] : null; }); | |
| const hands = new Hands({locateFile: (file) => `https://cdn.jsdelivr.net/npm/@mediapipe/hands/${file}`}); | |
| hands.setOptions({ maxNumHands: 2, modelComplexity: 0, minDetectionConfidence: 0.5, minTrackingConfidence: 0.5 }); | |
| hands.onResults((results) => { | |
| canvasCtx.save(); | |
| canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height); | |
| canvasCtx.drawImage(results.image, 0, 0, canvasElement.width, canvasElement.height); | |
| if (currentFaceLandmarks) { | |
| drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_TESSELATION, {color: '#06b6d4', lineWidth: 0.5}); | |
| drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_RIGHT_EYE, {color: '#ec4899', lineWidth: 2}); | |
| drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_LEFT_EYE, {color: '#ec4899', lineWidth: 2}); | |
| drawConnectors(canvasCtx, currentFaceLandmarks, FACEMESH_LIPS, {color: '#ec4899', lineWidth: 2}); | |
| const bio = analyzeFaceBiometrics(currentFaceLandmarks); | |
| valWajah.textContent = bio.faceText; valWajah.style.color = "#10b981"; | |
| valRahang.textContent = bio.jawText; valRahang.style.color = "#10b981"; | |
| valAlis.textContent = bio.browText; valAlis.style.color = "#10b981"; | |
| moodValue.textContent = bio.moodText; moodValue.style.color = bio.moodColor; | |
| genderValue.textContent = bio.genderText; genderValue.style.color = bio.genderColor; | |
| } else { | |
| valWajah.textContent = "Wajah Hilang"; valRahang.textContent = "Wajah Hilang"; valAlis.textContent = "Wajah Hilang"; | |
| valWajah.style.color = "#cbd5e1"; valRahang.style.color = "#cbd5e1"; valAlis.style.color = "#cbd5e1"; | |
| moodValue.textContent = "Menganalisis..."; moodValue.style.color = "#f8fafc"; | |
| genderValue.textContent = "Memindai..."; genderValue.style.color = "#f8fafc"; | |
| } | |
| let currentIds = []; | |
| anims.forEach(a => a.style.opacity = '0'); | |
| poseBoxes.forEach(b => b.classList.remove('active')); | |
| if (results.multiHandLandmarks && results.multiHandLandmarks.length > 0) { | |
| results.multiHandLandmarks.forEach((landmarks, index) => { | |
| drawConnectors(canvasCtx, landmarks, HAND_CONNECTIONS, {color: index === 0 ? '#ec4899' : '#06b6d4', lineWidth: 4}); | |
| drawLandmarks(canvasCtx, landmarks, {color: '#ffffff', lineWidth: 2, radius: 3}); | |
| let pose = classifyPose(landmarks); | |
| if (pose) { | |
| currentIds.push(pose.id); | |
| poseBoxes[pose.id - 1].classList.add('active'); | |
| if (pose.id === 1 && anims[index]) { | |
| const wrist = landmarks[0]; | |
| anims[index].style.opacity = '1'; | |
| anims[index].style.left = `${((1 - wrist.x) * canvasElement.width) - 75}px`; | |
| anims[index].style.top = `${(wrist.y * canvasElement.height) + 30}px`; | |
| anims[index].style.width = `150px`; | |
| } | |
| } | |
| }); | |
| } | |
| canvasCtx.restore(); | |
| if (currentIds.length > 0) { | |
| statusKiri.textContent = "Aktif & Responsif 🟢"; statusKiri.style.color = "#10b981"; | |
| let newPoses = currentIds.filter(id => !memoryActivePoses.includes(id)); | |
| if (newPoses.length > 0) { | |
| sounds.forEach(s => { s.pause(); s.currentTime = 0; }); | |
| const soundToPlay = sounds[newPoses[0] - 1]; | |
| if (soundToPlay) soundToPlay.play(); | |
| } | |
| memoryActivePoses = currentIds; | |
| memoryTimer = Date.now(); | |
| } else if (Date.now() - memoryTimer > 500) { | |
| statusKiri.textContent = "Menunggu Gerakan Jari 🟡"; statusKiri.style.color = "#eab308"; | |
| memoryActivePoses = []; | |
| } | |
| }); | |
| // --- SISTEM START DENGAN FORCE CAMERA PERMISSION --- | |
| startBtn.addEventListener('click', async () => { | |
| startBtn.style.display = 'none'; | |
| mainStatus.textContent = "Meminta Izin Kamera..."; | |
| mainStatus.style.color = "#eab308"; // Kuning warning | |
| // Unblock Audio | |
| sounds.forEach(s => { s.play().then(() => { s.pause(); s.currentTime = 0; }).catch(()=>{}); }); | |
| try { | |
| // PAKSA BROWSER MINTA IZIN KAMERA | |
| const stream = await navigator.mediaDevices.getUserMedia({ video: true }); | |
| videoElement.srcObject = stream; | |
| mainStatus.textContent = "Mendownload Otak AI (Tunggu 5-10 Detik)..."; | |
| mainStatus.style.color = "#38bdf8"; // Biru loading | |
| const camera = new Camera(videoElement, { | |
| onFrame: async () => { | |
| // Jalankan AI secara PARALEL agar tidak antri / lag | |
| await Promise.all([ | |
| faceMesh.send({image: videoElement}), | |
| hands.send({image: videoElement}) | |
| ]); | |
| // Ubah teks saat frame pertama berhasil masuk | |
| if (mainStatus.textContent.includes("Mendownload")) { | |
| mainStatus.textContent = "Sistem Aktif & Terkoneksi 🚀"; | |
| mainStatus.style.color = "#10b981"; // Hijau sukses | |
| } | |
| }, | |
| width: 640, | |
| height: 480 | |
| }); | |
| camera.start(); | |
| } catch (error) { | |
| // MUNCULKAN ERROR JIKA KAMERA DIBLOKIR / RUSAK | |
| alert("GAGAL MENGAKSES KAMERA! \nPastikan kamu sudah menekan 'Allow/Izinkan' pada *pop-up* browser. \n\nDetail Error: " + error.message); | |
| mainStatus.textContent = "Akses Kamera Ditolak / Error 🔴"; | |
| mainStatus.style.color = "#ef4444"; | |
| startBtn.style.display = 'block'; // Munculkan tombol lagi untuk coba ulang | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> |