{"id":24787661,"url":"https://github.com/vid852005/face-detection-using-siamese-neural-network","last_synced_at":"2026-05-08T14:14:26.297Z","repository":{"id":305856752,"uuid":"1007788758","full_name":"Vid852005/Face-Detection-using-Siamese-Neural-Network","owner":"Vid852005","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-24T15:14:13.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-22T11:35:48.524Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vid852005.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-24T14:28:33.000Z","updated_at":"2025-06-24T15:14:17.000Z","dependencies_parsed_at":"2025-07-22T11:35:52.186Z","dependency_job_id":"ba4fe177-9bb3-4657-8da2-46e1614a0fb4","html_url":"https://github.com/Vid852005/Face-Detection-using-Siamese-Neural-Network","commit_stats":null,"previous_names":["vid852005/face-detection-using-siamese-neural-network"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Vid852005/Face-Detection-using-Siamese-Neural-Network","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vid852005%2FFace-Detection-using-Siamese-Neural-Network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vid852005%2FFace-Detection-using-Siamese-Neural-Network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vid852005%2FFace-Detection-using-Siamese-Neural-Network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vid852005%2FFace-Detection-using-Siamese-Neural-Network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vid852005","download_url":"https://codeload.github.com/Vid852005/Face-Detection-using-Siamese-Neural-Network/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vid852005%2FFace-Detection-using-Siamese-Neural-Network/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278444495,"owners_count":25987788,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cnn","computer-vision","deep-learning","face-detection","face-recognition","keras-tensorflow","machine-learning","neural-network","nn","opencv","siamese-neural-network","tensorflow"],"created_at":"2025-01-29T16:13:00.483Z","updated_at":"2025-10-05T10:40:42.052Z","avatar_url":"https://github.com/Vid852005.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Face Detection and Verification using Siamese Neural Network\n\n## Overview\nThis project implements a face verification system using a Siamese Neural Network. The system can be trained on your own face images and then deployed as a web application using Flask, allowing users to verify their identity by uploading a photo.\n\n- **Anchor**: Reference images (usually your own face, collected via webcam)\n- **Positive**: More images of the same person (collected via webcam)\n- **Negative**: Images of other people (e.g., from the [LFW dataset](https://www.kaggle.com/datasets/jessicali9530/lfw-dataset))\n\nThe Siamese network learns to distinguish between images of the same person and different people by comparing anchor-positive and anchor-negative pairs.\n\n## Project Structure\n```\nproject-root/\n│\n├── app.py                  # Flask backend for web interface\n├── Facedetection.py        # Training script for Siamese model\n├── layer.py                # Custom L1 distance layer\n├── Siamese_model.keras     # Trained model (generated after training)\n├── templates/              # HTML templates for Flask\n│   ├── index.html\n│   └── result.html\n├── uploads/                # Uploaded images for verification (Flask)\n├── verification_images/    # Reference images for verification (Flask)\n├── data/                   # Training data (see below)\n│   ├── anchor/   # (Not included: your personal face images)\n│   ├── positive/ # (Not included: your personal face images)\n│   └── negative/ # (Not included, but recommended: LFW dataset from Kaggle)\n├── requirements.txt        # Python dependencies\n└── README.md\n```\n\n### Data Folder Details\n- **data/anchor/**: Place your own face images here (not included in this repo for privacy).\n- **data/positive/**: Place more images of your face here (not included in this repo for privacy).\n- **data/negative/**: Place images of other people here. Recommended: [Labeled Faces in the Wild (LFW)](https://www.kaggle.com/datasets/jessicali9530/lfw-dataset) from Kaggle.\n\n**Note:**\n- Personal images (anchor/positive) are not included in this repository for privacy reasons.\n- The negative images are from a public dataset and are not included due to size; please download them yourself.\n\n## Code Flow\n### 1. Data Collection \u0026 Training (`Facedetection.py`)\n- **Option to collect new images** via webcam or use existing images in `data/anchor`, `data/positive`, and `data/negative`.\n- **Pairs are created**: anchor-positive (label 1), anchor-negative (label 0).\n- **Mild data augmentation** is applied for robustness.\n- **Model is trained** with early stopping and a custom callback to halt when validation accuracy, precision, and recall all exceed 0.90.\n- **Trained model is saved** as `Siamese_model.keras`.\n\n### 2. Web App Deployment (`app.py`)\n- **Flask backend** loads the trained model and exposes a web interface.\n- **Users upload an image** via the frontend (`index.html`).\n- **The backend compares** the uploaded image to all images in `verification_images/` using the Siamese model.\n- **Result is shown** on `result.html` (\"Verified\" or \"Unverified\").\n\n## Setup \u0026 Usage\n### 1. Install Dependencies\n```bash\npip install -r requirements.txt\n```\n\n### 2. Prepare Data\n- Place anchor and positive images (your face) in `data/anchor` and `data/positive` (not included for privacy).\n- Place negative images (other faces) in `data/negative` (recommended: [LFW dataset](https://www.kaggle.com/datasets/jessicali9530/lfw-dataset)).\n- You can use the webcam collection option in `Facedetection.py` or add images manually.\n\n### 3. Train the Model\n```bash\npython Facedetection.py\n```\n- Choose whether to collect new images or use existing ones.\n- The model will stop early when validation metrics are high.\n\n### 4. Deploy the Web App\n```bash\npython app.py\n```\n- Open your browser at [http://127.0.0.1:5000/](http://127.0.0.1:5000/)\n- Upload an image to verify against your reference images in `verification_images/`.\n\n## Notes\n- **Do not retrain the model in the Flask app.** Only use the trained model for inference.\n- For best results, use a balanced and diverse dataset.\n- You can tune hyperparameters, batch size, and augmentation in `Facedetection.py`.\n- **Personal images are not included in this repository for privacy.**\n\n## Reference\n- [LFW Dataset](https://www.kaggle.com/datasets/jessicali9530/lfw-dataset)\n- [Siamese Neural Network Paper](https://www.cs.cmu.edu/~rsalakhu/papers/oneshot1.pdf)\n\n---\nFeel free to contribute or open issues for improvements!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvid852005%2Fface-detection-using-siamese-neural-network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvid852005%2Fface-detection-using-siamese-neural-network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvid852005%2Fface-detection-using-siamese-neural-network/lists"}