Spaces:
Sleeping
Sleeping
| title: Face Recognition System | |
| emoji: 👤 | |
| colorFrom: blue | |
| colorTo: purple | |
| sdk: gradio | |
| sdk_version: 4.0.0 | |
| app_file: app.py | |
| pinned: false | |
| license: mit | |
| short_description: A face recognition system using Siamese networks and cosine similarity | |
| # Face Recognition System | |
| A comprehensive face recognition system that can compare faces for similarity and classify faces into different categories. | |
| ## Features | |
| - **Face Similarity Comparison**: Compare two face images and get a similarity score | |
| - **Face Classification**: Classify a single face image into predefined categories | |
| - **Cosine Similarity**: Uses advanced cosine similarity for accurate face matching | |
| - **Siamese Neural Network**: Leverages deep learning for robust feature extraction | |
| ## How to Use | |
| ### Face Similarity | |
| 1. Upload two face images | |
| 2. Click "Compare Faces" | |
| 3. Get a similarity score and interpretation | |
| ### Face Classification | |
| 1. Upload a single face image | |
| 2. Click "Classify Face" | |
| 3. Get the predicted face class | |
| ## Similarity Score Interpretation | |
| - **0.8-1.0**: Very High Similarity (likely same person) | |
| - **0.6-0.8**: High Similarity (possibly same person) | |
| - **0.4-0.6**: Moderate Similarity (uncertain) | |
| - **0.2-0.4**: Low Similarity (likely different persons) | |
| - **0.0-0.2**: Very Low Similarity (definitely different persons) | |
| ## Technical Details | |
| - **Model**: Siamese Neural Network with CNN layers | |
| - **Similarity Metric**: Cosine Similarity | |
| - **Classifier**: K-Nearest Neighbors | |
| - **Preprocessing**: StandardScaler normalization | |
| - **Input Size**: 100x100 pixels (grayscale) | |
| ## API Usage | |
| The system also provides API endpoints: | |
| ### Similarity API | |
| ```bash | |
| curl -X POST \ | |
| -F "file1=@face1.jpg" \ | |
| -F "file2=@face2.jpg" \ | |
| https://pavaniyerra-hackthon4.hf.space/predict_similarity/ | |
| ``` | |
| ### Classification API | |
| ```bash | |
| curl -X POST \ | |
| -F "file=@face.jpg" \ | |
| https://pavaniyerra-hackthon4.hf.space/predict_class/ | |
| ``` | |
| ## Requirements | |
| - Python 3.11 | |
| - PyTorch | |
| - OpenCV | |
| - scikit-learn==1.6.1 | |
| - Gradio | |
| - NumPy | |
| - Pillow | |
| - Joblib | |
| ## Model Files | |
| The system requires these trained model files: | |
| - `siamese_model.t7`: Trained Siamese network | |
| - `decision_tree_model.sav`: KNN classifier | |
| - `face_recognition_scaler.sav`: StandardScaler for normalization | |