Download index.html from jpedrops/poseperfect-posture-wizard: direct link, hf CLI and curl.
- Browser
- Download file 24.1 kB
-
https://huggingface.co/spaces/jpedrops/poseperfect-posture-wizard/resolve/main/index.html
- Command line
-
hf download hf://spaces/jpedrops/poseperfect-posture-wizard/index.html
-
curl -L -o index.html https://huggingface.co/spaces/jpedrops/poseperfect-posture-wizard/resolve/main/index.html
24.1 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>PosePerfect - Real-time Posture Detection</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.waves.min.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@3.18.0/dist/tf.min.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/@mediapipe/pose/pose.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/pose-detection@0.0.6"></script> | |
| <style> | |
| #vanta-bg { | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| z-index: -1; | |
| } | |
| #video-container { | |
| position: relative; | |
| width: 100%; | |
| max-width: 640px; | |
| margin: 0 auto; | |
| box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); | |
| border-radius: 20px; | |
| overflow: hidden; | |
| background: rgba(255, 255, 255, 0.1); | |
| backdrop-filter: blur(10px); | |
| border: 1px solid rgba(255, 255, 255, 0.2); | |
| } | |
| #video, #canvas { | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: auto; | |
| border-radius: 20px; | |
| } | |
| .keypoint { | |
| position: absolute; | |
| width: 10px; | |
| height: 10px; | |
| border-radius: 50%; | |
| background-color: #3B82F6; | |
| transform: translate(-50%, -50%); | |
| box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8); | |
| } | |
| .skeleton-line { | |
| position: absolute; | |
| background-color: #3B82F6; | |
| height: 3px; | |
| transform-origin: 0 0; | |
| opacity: 0.7; | |
| } | |
| .pulse-animation { | |
| animation: pulse 2s infinite; | |
| } | |
| @keyframes pulse { | |
| 0% { transform: scale(1); opacity: 1; } | |
| 50% { transform: scale(1.1); opacity: 0.7; } | |
| 100% { transform: scale(1); opacity: 1; } | |
| } | |
| .glass-card { | |
| background: rgba(255, 255, 255, 0.1); | |
| backdrop-filter: blur(10px); | |
| border: 1px solid rgba(255, 255, 255, 0.2); | |
| border-radius: 16px; | |
| } | |
| </style> | |
| </head> | |
| <body class="min-h-screen text-gray-800"> | |
| <div id="vanta-bg"></div> | |
| <div class="container mx-auto px-4 py-12 relative z-10"> | |
| <!-- Floating Nav --> | |
| <nav class="flex justify-between items-center mb-16 glass-card p-4"> | |
| <div class="flex items-center space-x-2"> | |
| <i data-feather="activity" class="text-blue-500"></i> | |
| <span class="text-xl font-bold text-transparent bg-clip-text bg-gradient-to-r from-blue-500 to-purple-600">PosePerfect</span> | |
| </div> | |
| <div class="flex space-x-4"> | |
| <button class="text-sm font-medium text-gray-700 hover:text-blue-600 transition">About</button> | |
| <button class="text-sm font-medium text-gray-700 hover:text-blue-600 transition">Guide</button> | |
| <button class="text-sm font-medium text-gray-700 hover:text-blue-600 transition">Contact</button> | |
| </div> | |
| </nav> | |
| <!-- Hero Section --> | |
| <div class="text-center mb-16"> | |
| <h1 class="text-5xl md:text-6xl font-bold mb-6 text-white"> | |
| Perfect Your <span class="text-transparent bg-clip-text bg-gradient-to-r from-blue-400 to-purple-500">Posture</span> | |
| </h1> | |
| <p class="text-xl text-gray-300 max-w-2xl mx-auto mb-8"> | |
| Real-time body pose detection with AI magic. Improve your posture, track movements, and stay healthy. | |
| </p> | |
| <div class="flex justify-center space-x-4"> | |
| <button id="startBtn" class="bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white px-8 py-4 rounded-full font-medium transition duration-200 flex items-center shadow-lg pulse-animation"> | |
| <i data-feather="play" class="mr-3"></i> Start Detection | |
| </button> | |
| <button class="bg-white bg-opacity-20 hover:bg-opacity-30 text-white px-8 py-4 rounded-full font-medium transition duration-200 flex items-center border border-white border-opacity-30"> | |
| <i data-feather="info" class="mr-3"></i> Learn More | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Video Container --> | |
| <div id="video-container" class="mb-16"> | |
| <video id="video" class="w-full" playsinline></video> | |
| <canvas id="canvas" class="w-full"></canvas> | |
| <div id="keypoints-container"></div> | |
| <div id="skeleton-container"></div> | |
| </div> | |
| <!-- Stats Dashboard --> | |
| <div class="glass-card p-8 rounded-2xl mb-16"> | |
| <div class="flex flex-col md:flex-row justify-between items-center mb-8"> | |
| <div> | |
| <h3 class="text-2xl font-bold text-white">Pose Analytics</h3> | |
| <p class="text-gray-300">Real-time posture metrics and feedback</p> | |
| </div> | |
| <div id="detectionStatus" class="px-4 py-2 bg-yellow-500 bg-opacity-20 text-yellow-200 rounded-full text-sm font-medium mt-4 md:mt-0"> | |
| <i data-feather="clock" class="inline mr-2"></i> Waiting to start | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-6"> | |
| <div class="bg-white bg-opacity-10 p-6 rounded-xl border border-white border-opacity-10"> | |
| <div class="flex justify-between items-start mb-2"> | |
| <div> | |
| <p class="text-sm text-blue-300 font-medium">Confidence Score</p> | |
| <p id="scoreValue" class="text-3xl font-bold text-white">0.00</p> | |
| </div> | |
| <div class="bg-blue-500 bg-opacity-20 p-2 rounded-lg"> | |
| <i data-feather="bar-chart-2" class="text-blue-300"></i> | |
| </div> | |
| </div> | |
| <div class="h-2 bg-blue-500 bg-opacity-20 rounded-full mt-2 overflow-hidden"> | |
| <div id="scoreBar" class="h-full bg-blue-500 rounded-full" style="width: 0%"></div> | |
| </div> | |
| </div> | |
| <div class="bg-white bg-opacity-10 p-6 rounded-xl border border-white border-opacity-10"> | |
| <div class="flex justify-between items-start mb-2"> | |
| <div> | |
| <p class="text-sm text-purple-300 font-medium">Poses Detected</p> | |
| <p id="poseCount" class="text-3xl font-bold text-white">0</p> | |
| </div> | |
| <div class="bg-purple-500 bg-opacity-20 p-2 rounded-lg"> | |
| <i data-feather="users" class="text-purple-300"></i> | |
| </div> | |
| </div> | |
| <p class="text-xs text-purple-300 mt-2">+0% from last session</p> | |
| </div> | |
| <div class="bg-white bg-opacity-10 p-6 rounded-xl border border-white border-opacity-10"> | |
| <div class="flex justify-between items-start mb-2"> | |
| <div> | |
| <p class="text-sm text-green-300 font-medium">Posture Quality</p> | |
| <p id="postureQuality" class="text-3xl font-bold text-white">Neutral</p> | |
| </div> | |
| <div class="bg-green-500 bg-opacity-20 p-2 rounded-lg"> | |
| <i data-feather="thumbs-up" class="text-green-300"></i> | |
| </div> | |
| </div> | |
| <div class="flex space-x-1 mt-2"> | |
| <div class="h-2 flex-1 bg-gray-500 bg-opacity-20 rounded-full"></div> | |
| <div class="h-2 flex-1 bg-gray-500 bg-opacity-20 rounded-full"></div> | |
| <div class="h-2 flex-1 bg-gray-500 bg-opacity-20 rounded-full"></div> | |
| <div class="h-2 flex-1 bg-gray-500 bg-opacity-20 rounded-full"></div> | |
| <div class="h-2 flex-1 bg-gray-500 bg-opacity-20 rounded-full"></div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Control Panel --> | |
| <div class="flex flex-col items-center space-y-6 mb-16"> | |
| <div class="flex flex-wrap justify-center gap-4"> | |
| <button id="startBtn" class="bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white px-8 py-4 rounded-full font-medium transition duration-200 flex items-center shadow-lg"> | |
| <i data-feather="play" class="mr-3"></i> Start Detection | |
| </button> | |
| <button id="stopBtn" class="bg-gray-700 hover:bg-gray-800 text-white px-8 py-4 rounded-full font-medium transition duration-200 flex items-center" disabled> | |
| <i data-feather="stop-circle" class="mr-3"></i> Stop Detection | |
| </button> | |
| <button id="downloadBtn" class="hidden bg-gradient-to-r from-green-500 to-teal-600 hover:from-green-600 hover:to-teal-700 text-white px-8 py-4 rounded-full font-medium transition duration-200 flex items-center shadow-lg"> | |
| <i data-feather="download" class="mr-3"></i> Export Data | |
| </button> | |
| <button id="screenshotBtn" class="bg-gradient-to-r from-pink-500 to-rose-600 hover:from-pink-600 hover:to-rose-700 text-white px-8 py-4 rounded-full font-medium transition duration-200 flex items-center shadow-lg"> | |
| <i data-feather="camera" class="mr-3"></i> Capture Pose | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Features Section --> | |
| <div class="glass-card p-8 rounded-2xl mb-16"> | |
| <h3 class="text-2xl font-bold text-white mb-8">Why PosePerfect?</h3> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-8"> | |
| <div class="bg-white bg-opacity-5 p-6 rounded-xl border border-white border-opacity-10 hover:border-opacity-30 transition"> | |
| <div class="bg-blue-500 bg-opacity-20 p-3 rounded-lg w-12 h-12 flex items-center justify-center mb-4"> | |
| <i data-feather="eye" class="text-blue-300"></i> | |
| </div> | |
| <h4 class="text-xl font-semibold text-white mb-2">Real-time Tracking</h4> | |
| <p class="text-gray-300">Instant feedback on your posture and body position with millisecond precision.</p> | |
| </div> | |
| <div class="bg-white bg-opacity-5 p-6 rounded-xl border border-white border-opacity-10 hover:border-opacity-30 transition"> | |
| <div class="bg-purple-500 bg-opacity-20 p-3 rounded-lg w-12 h-12 flex items-center justify-center mb-4"> | |
| <i data-feather="trending-up" class="text-purple-300"></i> | |
| </div> | |
| <h4 class="text-xl font-semibold text-white mb-2">Health Analytics</h4> | |
| <p class="text-gray-300">Track your posture habits over time and get personalized improvement suggestions.</p> | |
| </div> | |
| <div class="bg-white bg-opacity-5 p-6 rounded-xl border border-white border-opacity-10 hover:border-opacity-30 transition"> | |
| <div class="bg-green-500 bg-opacity-20 p-3 rounded-lg w-12 h-12 flex items-center justify-center mb-4"> | |
| <i data-feather="shield" class="text-green-300"></i> | |
| </div> | |
| <h4 class="text-xl font-semibold text-white mb-2">Privacy Focused</h4> | |
| <p class="text-gray-300">All processing happens in your browser. No data is ever sent to our servers.</p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Footer --> | |
| <footer class="text-center text-gray-400 text-sm"> | |
| <div class="flex justify-center space-x-6 mb-6"> | |
| <a href="#" class="hover:text-white transition"><i data-feather="github"></i></a> | |
| <a href="#" class="hover:text-white transition"><i data-feather="twitter"></i></a> | |
| <a href="#" class="hover:text-white transition"><i data-feather="instagram"></i></a> | |
| <a href="#" class="hover:text-white transition"><i data-feather="linkedin"></i></a> | |
| </div> | |
| <p>© 2023 PosePerfect. All rights reserved.</p> | |
| <p class="mt-2">Powered by TensorFlow.js & MediaPipe Pose</p> | |
| </footer> | |
| </div> | |
| <script> | |
| // Initialize Vanta.js background | |
| VANTA.WAVES({ | |
| el: "#vanta-bg", | |
| mouseControls: true, | |
| touchControls: true, | |
| gyroControls: false, | |
| minHeight: 200.00, | |
| minWidth: 200.00, | |
| scale: 1.00, | |
| scaleMobile: 1.00, | |
| color: 0x1e3a8a, | |
| shininess: 35.00, | |
| waveHeight: 15.00, | |
| waveSpeed: 0.75, | |
| zoom: 0.85 | |
| }); | |
| // Initialize pose detection | |
| let detector; | |
| let video; | |
| let canvas; | |
| let ctx; | |
| let isDetecting = false; | |
| let poseCount = 0; | |
| let animationId; | |
| async function initPoseDetection() { | |
| await tf.ready(); | |
| const model = poseDetection.SupportedModels.MoveNet; | |
| const detectorConfig = { | |
| modelType: poseDetection.movenet.modelType.SINGLEPOSE_THUNDER, | |
| enableSmoothing: true | |
| }; | |
| detector = await poseDetection.createDetector(model, detectorConfig); | |
| video = document.getElementById('video'); | |
| canvas = document.getElementById('canvas'); | |
| ctx = canvas.getContext('2d'); | |
| try { | |
| const stream = await navigator.mediaDevices.getUserMedia({ | |
| video: { facingMode: 'user', width: 640, height: 480 }, | |
| audio: false | |
| }); | |
| video.srcObject = stream; | |
| video.onloadedmetadata = () => { | |
| video.play(); | |
| canvas.width = video.videoWidth; | |
| canvas.height = video.videoHeight; | |
| }; | |
| } catch (err) { | |
| console.error("Error accessing camera:", err); | |
| alert("Could not access the camera. Please ensure you've granted camera permissions."); | |
| } | |
| } | |
| async function detectPose() { | |
| if (!isDetecting) return; | |
| try { | |
| const poses = await detector.estimatePoses(video); | |
| drawPoses(poses); | |
| if (poses.length > 0) { | |
| poseCount++; | |
| document.getElementById('poseCount').textContent = poseCount; | |
| const score = poses[0].score; | |
| document.getElementById('scoreValue').textContent = score.toFixed(2); | |
| document.getElementById('scoreBar').style.width = `${score * 100}%`; | |
| // Simple posture quality detection | |
| const keypoints = poses[0].keypoints; | |
| const leftShoulder = keypoints.find(k => k.name === 'left_shoulder'); | |
| const rightShoulder = keypoints.find(k => k.name === 'right_shoulder'); | |
| const nose = keypoints.find(k => k.name === 'nose'); | |
| if (leftShoulder && rightShoulder && nose) { | |
| const shoulderDiff = Math.abs(leftShoulder.y - rightShoulder.y); | |
| const headAlignment = Math.abs(nose.x - (leftShoulder.x + rightShoulder.x) / 2); | |
| let quality; | |
| if (shoulderDiff < 20 && headAlignment < 15) { | |
| quality = "Excellent"; | |
| } else if (shoulderDiff < 40 && headAlignment < 30) { | |
| quality = "Good"; | |
| } else { | |
| quality = "Needs Work"; | |
| } | |
| document.getElementById('postureQuality').textContent = quality; | |
| } | |
| document.getElementById('detectionStatus').innerHTML = '<i data-feather="check-circle" class="inline mr-2"></i> Detection active'; | |
| document.getElementById('detectionStatus').className = 'px-4 py-2 bg-green-500 bg-opacity-20 text-green-200 rounded-full text-sm font-medium'; | |
| } else { | |
| document.getElementById('detectionStatus').innerHTML = '<i data-feather="alert-circle" class="inline mr-2"></i> No pose detected'; | |
| document.getElementById('detectionStatus').className = 'px-4 py-2 bg-red-500 bg-opacity-20 text-red-200 rounded-full text-sm font-medium'; | |
| } | |
| } catch (error) { | |
| console.error("Error detecting pose:", error); | |
| document.getElementById('detectionStatus').innerHTML = '<i data-feather="alert-triangle" class="inline mr-2"></i> Detection error'; | |
| document.getElementById('detectionStatus').className = 'px-4 py-2 bg-red-500 bg-opacity-20 text-red-200 rounded-full text-sm font-medium'; | |
| } | |
| animationId = requestAnimationFrame(detectPose); | |
| } | |
| function drawPoses(poses) { | |
| ctx.clearRect(0, 0, canvas.width, canvas.height); | |
| // Draw video frame | |
| ctx.save(); | |
| ctx.scale(-1, 1); | |
| ctx.drawImage(video, -canvas.width, 0, canvas.width, canvas.height); | |
| ctx.restore(); | |
| const keypointsContainer = document.getElementById('keypoints-container'); | |
| const skeletonContainer = document.getElementById('skeleton-container'); | |
| keypointsContainer.innerHTML = ''; | |
| skeletonContainer.innerHTML = ''; | |
| if (poses.length > 0) { | |
| const pose = poses[0]; | |
| const keypoints = pose.keypoints; | |
| // Draw keypoints | |
| keypoints.forEach(keypoint => { | |
| if (keypoint.score > 0.3) { | |
| const keypointElement = document.createElement('div'); | |
| keypointElement.className = 'keypoint'; | |
| keypointElement.style.left = `${keypoint.x}px`; | |
| keypointElement.style.top = `${keypoint.y}px`; | |
| keypointsContainer.appendChild(keypointElement); | |
| } | |
| }); | |
| // Draw skeleton (simplified) | |
| const connections = [ | |
| ['left_shoulder', 'right_shoulder'], | |
| ['left_shoulder', 'left_elbow'], | |
| ['left_elbow', 'left_wrist'], | |
| ['right_shoulder', 'right_elbow'], | |
| ['right_elbow', 'right_wrist'], | |
| ['left_shoulder', 'left_hip'], | |
| ['right_shoulder', 'right_hip'], | |
| ['left_hip', 'right_hip'], | |
| ['left_hip', 'left_knee'], | |
| ['left_knee', 'left_ankle'], | |
| ['right_hip', 'right_knee'], | |
| ['right_knee', 'right_ankle'] | |
| ]; | |
| connections.forEach(([name1, name2]) => { | |
| const kp1 = keypoints.find(k => k.name === name1); | |
| const kp2 = keypoints.find(k => k.name === name2); | |
| if (kp1 && kp2 && kp1.score > 0.3 && kp2.score > 0.3) { | |
| const line = document.createElement('div'); | |
| line.className = 'skeleton-line'; | |
| const length = Math.sqrt(Math.pow(kp2.x - kp1.x, 2) + Math.pow(kp2.y - kp1.y, 2)); | |
| const angle = Math.atan2(kp2.y - kp1.y, kp2.x - kp1.x) * 180 / Math.PI; | |
| line.style.width = `${length}px`; | |
| line.style.left = `${kp1.x}px`; | |
| line.style.top = `${kp1.y}px`; | |
| line.style.transform = `rotate(${angle}deg)`; | |
| skeletonContainer.appendChild(line); | |
| } | |
| }); | |
| } | |
| } | |
| document.getElementById('startBtn').addEventListener('click', async () => { | |
| if (!detector) { | |
| await initPoseDetection(); | |
| } | |
| isDetecting = true; | |
| document.getElementById('startBtn').disabled = true; | |
| document.getElementById('stopBtn').disabled = false; | |
| document.getElementById('downloadBtn').classList.remove('hidden'); | |
| document.getElementById('detectionStatus').innerHTML = '<i data-feather="activity" class="inline mr-2"></i> Detecting...'; | |
| document.getElementById('detectionStatus').className = 'px-4 py-2 bg-blue-500 bg-opacity-20 text-blue-200 rounded-full text-sm font-medium'; | |
| detectPose(); | |
| }); | |
| document.getElementById('stopBtn').addEventListener('click', () => { | |
| isDetecting = false; | |
| cancelAnimationFrame(animationId); | |
| document.getElementById('startBtn').disabled = false; | |
| document.getElementById('stopBtn').disabled = true; | |
| document.getElementById('detectionStatus').innerHTML = '<i data-feather="pause" class="inline mr-2"></i> Detection paused'; | |
| document.getElementById('detectionStatus').className = 'px-4 py-2 bg-yellow-500 bg-opacity-20 text-yellow-200 rounded-full text-sm font-medium'; | |
| }); | |
| document.getElementById('downloadBtn').addEventListener('click', () => { | |
| const data = { | |
| poseCount, | |
| timestamp: new Date().toISOString(), | |
| message: "Pose data captured by PosePerfect" | |
| }; | |
| const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' }); | |
| const url = URL.createObjectURL(blob); | |
| const a = document.createElement('a'); | |
| a.href = url; | |
| a.download = `poseperfect-data-${new Date().toISOString().slice(0, 10)}.json`; | |
| document.body.appendChild(a); | |
| a.click(); | |
| document.body.removeChild(a); | |
| URL.revokeObjectURL(url); | |
| }); | |
| document.getElementById('screenshotBtn').addEventListener('click', () => { | |
| const tempCanvas = document.createElement('canvas'); | |
| tempCanvas.width = canvas.width; | |
| tempCanvas.height = canvas.height; | |
| const tempCtx = tempCanvas.getContext('2d'); | |
| tempCtx.drawImage(canvas, 0, 0); | |
| // Add watermark | |
| tempCtx.font = '16px Arial'; | |
| tempCtx.fillStyle = 'rgba(255, 255, 255, 0.7)'; | |
| tempCtx.fillText('PosePerfect Capture', 20, tempCanvas.height - 20); | |
| const url = tempCanvas.toDataURL('image/png'); | |
| const a = document.createElement('a'); | |
| a.href = url; | |
| a.download = `pose-capture-${new Date().toISOString().slice(0, 10)}.png`; | |
| document.body.appendChild(a); | |
| a.click(); | |
| document.body.removeChild(a); | |
| }); | |
| feather.replace(); | |
| </script> | |
| </body> | |
| </html> | |