Spaces:
Build error
Build error
Hkoradiya123
feat: Initialize frontend with Zustand for state management, Tailwind CSS for styling, and TypeScript for type safety
4854e2b Download backend/static/index.html from jinksQspider/fmproService: direct link, hf CLI and curl.
- Browser
- Download file 13.3 kB
-
https://huggingface.co/spaces/jinksQspider/fmproService/resolve/main/backend/static/index.html
- Command line
-
hf download hf://spaces/jinksQspider/fmproService/backend/static/index.html
-
curl -L -o index.html https://huggingface.co/spaces/jinksQspider/fmproService/resolve/main/backend/static/index.html
13.3 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Face Inference Service</title> | |
| <style> | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| } | |
| body { | |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
| min-height: 100vh; | |
| padding: 20px; | |
| color: #333; | |
| } | |
| .container { | |
| max-width: 900px; | |
| margin: 0 auto; | |
| } | |
| header { | |
| text-align: center; | |
| color: white; | |
| margin-bottom: 30px; | |
| } | |
| header h1 { | |
| font-size: 2.5rem; | |
| margin-bottom: 10px; | |
| text-shadow: 2px 2px 4px rgba(0,0,0,0.3); | |
| } | |
| header p { | |
| font-size: 1.1rem; | |
| opacity: 0.95; | |
| } | |
| .card { | |
| background: white; | |
| border-radius: 15px; | |
| padding: 30px; | |
| box-shadow: 0 10px 30px rgba(0,0,0,0.3); | |
| margin-bottom: 20px; | |
| } | |
| .upload-section { | |
| text-align: center; | |
| margin-bottom: 30px; | |
| } | |
| .upload-area { | |
| border: 3px dashed #667eea; | |
| border-radius: 10px; | |
| padding: 40px; | |
| transition: all 0.3s ease; | |
| cursor: pointer; | |
| background: #f8f9ff; | |
| } | |
| .upload-area:hover { | |
| border-color: #764ba2; | |
| background: #f0f1ff; | |
| } | |
| .upload-area.dragover { | |
| background: #e8e9ff; | |
| border-color: #764ba2; | |
| } | |
| .upload-icon { | |
| font-size: 3rem; | |
| margin-bottom: 15px; | |
| } | |
| input[type="file"] { | |
| display: none; | |
| } | |
| .btn { | |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
| color: white; | |
| border: none; | |
| padding: 12px 30px; | |
| border-radius: 25px; | |
| font-size: 1rem; | |
| cursor: pointer; | |
| transition: transform 0.2s; | |
| margin: 5px; | |
| box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4); | |
| } | |
| .btn:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6); | |
| } | |
| .btn:active { | |
| transform: translateY(0); | |
| } | |
| .btn:disabled { | |
| opacity: 0.5; | |
| cursor: not-allowed; | |
| } | |
| .preview-section { | |
| margin: 20px 0; | |
| text-align: center; | |
| } | |
| .preview-image { | |
| max-width: 100%; | |
| max-height: 400px; | |
| border-radius: 10px; | |
| box-shadow: 0 5px 15px rgba(0,0,0,0.2); | |
| display: none; | |
| } | |
| .results-section { | |
| margin-top: 30px; | |
| } | |
| .result-item { | |
| background: #f8f9ff; | |
| padding: 15px; | |
| border-radius: 8px; | |
| margin: 10px 0; | |
| border-left: 4px solid #667eea; | |
| } | |
| .result-item h4 { | |
| color: #667eea; | |
| margin-bottom: 8px; | |
| } | |
| .result-item pre { | |
| background: white; | |
| padding: 12px; | |
| border-radius: 5px; | |
| overflow-x: auto; | |
| font-size: 0.85rem; | |
| max-height: 300px; | |
| overflow-y: auto; | |
| } | |
| .status { | |
| padding: 8px 15px; | |
| border-radius: 20px; | |
| display: inline-block; | |
| font-size: 0.9rem; | |
| margin: 10px 0; | |
| } | |
| .status.success { | |
| background: #d4edda; | |
| color: #155724; | |
| } | |
| .status.error { | |
| background: #f8d7da; | |
| color: #721c24; | |
| } | |
| .status.info { | |
| background: #d1ecf1; | |
| color: #0c5460; | |
| } | |
| .loading { | |
| display: none; | |
| text-align: center; | |
| margin: 20px 0; | |
| } | |
| .spinner { | |
| border: 4px solid #f3f3f3; | |
| border-top: 4px solid #667eea; | |
| border-radius: 50%; | |
| width: 40px; | |
| height: 40px; | |
| animation: spin 1s linear infinite; | |
| margin: 0 auto; | |
| } | |
| @keyframes spin { | |
| 0% { transform: rotate(0deg); } | |
| 100% { transform: rotate(360deg); } | |
| } | |
| .api-docs { | |
| background: #f8f9ff; | |
| padding: 20px; | |
| border-radius: 10px; | |
| margin-top: 20px; | |
| } | |
| .api-docs h3 { | |
| color: #667eea; | |
| margin-bottom: 15px; | |
| } | |
| .endpoint { | |
| background: white; | |
| padding: 12px; | |
| border-radius: 5px; | |
| margin: 10px 0; | |
| font-family: 'Courier New', monospace; | |
| font-size: 0.9rem; | |
| } | |
| .endpoint .method { | |
| color: #28a745; | |
| font-weight: bold; | |
| margin-right: 10px; | |
| } | |
| footer { | |
| text-align: center; | |
| color: white; | |
| margin-top: 30px; | |
| opacity: 0.9; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <header> | |
| <h1>π Face Inference Service</h1> | |
| <p>AI-Powered Face Detection & Recognition API</p> | |
| </header> | |
| <div class="card"> | |
| <div class="upload-section"> | |
| <h2 style="margin-bottom: 20px; color: #667eea;">Test Face Detection</h2> | |
| <div class="upload-area" id="uploadArea"> | |
| <div class="upload-icon">πΈ</div> | |
| <h3>Click or Drop Image Here</h3> | |
| <p style="color: #666; margin-top: 10px;">Supported formats: JPG, PNG</p> | |
| <input type="file" id="fileInput" accept="image/*"> | |
| </div> | |
| </div> | |
| <div class="preview-section"> | |
| <img id="previewImage" class="preview-image" alt="Preview"> | |
| </div> | |
| <div style="text-align: center; margin: 20px 0;"> | |
| <button class="btn" id="testEmbeddingBtn" disabled>π Extract Face Embedding</button> | |
| <button class="btn" id="clearBtn">ποΈ Clear</button> | |
| </div> | |
| <div class="loading" id="loading"> | |
| <div class="spinner"></div> | |
| <p style="margin-top: 10px; color: #667eea;">Processing...</p> | |
| </div> | |
| <div class="results-section" id="results" style="display: none;"> | |
| <h3 style="color: #667eea; margin-bottom: 15px;">Results</h3> | |
| <div id="resultContent"></div> | |
| </div> | |
| </div> | |
| <div class="card api-docs"> | |
| <h3>π API Endpoints</h3> | |
| <div class="endpoint"> | |
| <span class="method">GET</span> /health | |
| <p style="color: #666; margin-top: 5px; font-family: 'Segoe UI';">Health check endpoint</p> | |
| </div> | |
| <div class="endpoint"> | |
| <span class="method">POST</span> /get_embedding | |
| <p style="color: #666; margin-top: 5px; font-family: 'Segoe UI';">Extract face embedding from image</p> | |
| </div> | |
| <div class="endpoint"> | |
| <span class="method">POST</span> /recognize | |
| <p style="color: #666; margin-top: 5px; font-family: 'Segoe UI';">Recognize faces against known encodings</p> | |
| </div> | |
| <div class="endpoint"> | |
| <span class="method">POST</span> /recognize_batch | |
| <p style="color: #666; margin-top: 5px; font-family: 'Segoe UI';">Batch recognition for multiple frames</p> | |
| </div> | |
| </div> | |
| <footer> | |
| <p>Built with FastAPI + InsightFace | Running on Hugging Face Spaces π</p> | |
| </footer> | |
| </div> | |
| <script> | |
| const uploadArea = document.getElementById('uploadArea'); | |
| const fileInput = document.getElementById('fileInput'); | |
| const previewImage = document.getElementById('previewImage'); | |
| const testEmbeddingBtn = document.getElementById('testEmbeddingBtn'); | |
| const clearBtn = document.getElementById('clearBtn'); | |
| const loading = document.getElementById('loading'); | |
| const results = document.getElementById('results'); | |
| const resultContent = document.getElementById('resultContent'); | |
| let selectedFile = null; | |
| // Click to upload | |
| uploadArea.addEventListener('click', () => fileInput.click()); | |
| // File input change | |
| fileInput.addEventListener('change', (e) => { | |
| handleFile(e.target.files[0]); | |
| }); | |
| // Drag and drop | |
| uploadArea.addEventListener('dragover', (e) => { | |
| e.preventDefault(); | |
| uploadArea.classList.add('dragover'); | |
| }); | |
| uploadArea.addEventListener('dragleave', () => { | |
| uploadArea.classList.remove('dragover'); | |
| }); | |
| uploadArea.addEventListener('drop', (e) => { | |
| e.preventDefault(); | |
| uploadArea.classList.remove('dragover'); | |
| handleFile(e.dataTransfer.files[0]); | |
| }); | |
| function handleFile(file) { | |
| if (!file || !file.type.startsWith('image/')) { | |
| alert('Please select a valid image file'); | |
| return; | |
| } | |
| selectedFile = file; | |
| const reader = new FileReader(); | |
| reader.onload = (e) => { | |
| previewImage.src = e.target.result; | |
| previewImage.style.display = 'block'; | |
| testEmbeddingBtn.disabled = false; | |
| results.style.display = 'none'; | |
| }; | |
| reader.readAsDataURL(file); | |
| } | |
| // Test embedding extraction | |
| testEmbeddingBtn.addEventListener('click', async () => { | |
| if (!selectedFile) return; | |
| const reader = new FileReader(); | |
| reader.onload = async (e) => { | |
| const base64Data = e.target.result; | |
| loading.style.display = 'block'; | |
| results.style.display = 'none'; | |
| testEmbeddingBtn.disabled = true; | |
| try { | |
| const formData = new FormData(); | |
| formData.append('image_data', base64Data); | |
| const response = await fetch('/get_embedding', { | |
| method: 'POST', | |
| body: formData | |
| }); | |
| const data = await response.json(); | |
| loading.style.display = 'none'; | |
| results.style.display = 'block'; | |
| testEmbeddingBtn.disabled = false; | |
| if (data.success) { | |
| resultContent.innerHTML = ` | |
| <div class="status success">β Face Detected Successfully</div> | |
| <div class="result-item"> | |
| <h4>Detection Info</h4> | |
| <p><strong>Faces Detected:</strong> ${data.faces_detected}</p> | |
| <p><strong>Embedding Dimensions:</strong> ${data.embedding.length}</p> | |
| </div> | |
| <div class="result-item"> | |
| <h4>Face Embedding Vector (first 10 values)</h4> | |
| <pre>${JSON.stringify(data.embedding.slice(0, 10), null, 2)}...</pre> | |
| </div> | |
| `; | |
| } else { | |
| resultContent.innerHTML = ` | |
| <div class="status error">β ${data.detail || 'Processing failed'}</div> | |
| `; | |
| } | |
| } catch (error) { | |
| loading.style.display = 'none'; | |
| results.style.display = 'block'; | |
| testEmbeddingBtn.disabled = false; | |
| resultContent.innerHTML = ` | |
| <div class="status error">β Error: ${error.message}</div> | |
| `; | |
| } | |
| }; | |
| reader.readAsDataURL(selectedFile); | |
| }); | |
| // Clear | |
| clearBtn.addEventListener('click', () => { | |
| selectedFile = null; | |
| fileInput.value = ''; | |
| previewImage.style.display = 'none'; | |
| previewImage.src = ''; | |
| testEmbeddingBtn.disabled = true; | |
| results.style.display = 'none'; | |
| loading.style.display = 'none'; | |
| }); | |
| // Check service health on load | |
| window.addEventListener('load', async () => { | |
| try { | |
| const response = await fetch('/health'); | |
| const data = await response.json(); | |
| console.log('Service health:', data); | |
| } catch (error) { | |
| console.error('Health check failed:', error); | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> | |