This project is a face recognition system with a Flask backend and a Flutter frontend. The Flask server uses YOLO for face detection and FaceNet for face embedding extraction. The Flutter app allows users to select an image from their gallery and upload it to the server. The server processes the image, detects faces, extracts embeddings, and calculates similarity. The similarity results are then displayed in the Flutter app.
- Face Detection: The Flask backend uses the YOLO model to detect faces in the uploaded image.
- Face Embedding Extraction: Detected face regions are extracted and passed to the FaceNet model to generate embedding vectors.
- Similarity Calculation: The similarity between embeddings is calculated using two metrics:
- Euclidean Distance: Measures the straight-line distance between two embedding vectors.
- Cosine Similarity: Measures the cosine of the angle between two embedding vectors.
- Results Handling: The similarity results, including Euclidean distance and cosine similarity, are sent back to the Flutter app and displayed to the user.
- Python 3.6+
- Flask
- OpenCV
- TensorFlow
- Pillow
- Keras-FaceNet
- Ultralytics YOLO
- SciPy
- Flutter SDK
- Dart
-
Clone the repository:
git clone https://github.com/yunseoLee0343/embedded.git cd embedded_final/embedded_backend
-
Install the required packages:
pip install -r requirements.txt
-
Place your dataset of images in the
face_features_88
directory. Ensure that the images are in JPG format. -
Start the Flask app:
python app.py
-
The Flask app will be running at
http://127.0.0.1:5000
.
-
Clone the repository:
git clone https://github.com/yourusername/face-recognition-flask.git cd face-recognition-flutter/frontend
-
Ensure you have Flutter installed. If not, follow the instructions on the Flutter official website.
-
Open the project in your preferred IDE (e.g., VSCode, Android Studio).
-
Run the Flutter app on an emulator or physical device:
flutter run
Endpoint: /detect_faces
Method: POST
Description: Detects faces in an uploaded image.
Request:
image
: The image file to be uploaded.
Response:
```json
{
"detections": [[x1, y1, x2, y2], ...]
}
```
Endpoint: /process_images
Method: GET
Description: Processes images in the dataset directory, detects faces, extracts embeddings, and calculates the similarity between the first two images.
Response:
```json
{
"Embeddings for the first image": [embedding vector],
"Embeddings for the second image": [embedding vector],
"Euclidean Distance": euclidean_distance_value,
"Cosine Similarity": cosine_similarity_value
}
```
Endpoint: /show_images
Method: GET
Description: Returns the processed images with detected faces and bounding boxes.
Response:
```json
{
"images": [image_bytes, ...]
}
```
-
The Flutter app allows users to pick an image from their gallery and upload it to the Flask backend for face detection and similarity calculation.
-
The similarity result is displayed in the Flutter app once the image is processed.
-
Ensure you have placed images in the
face_features_88
directory. -
Start the Flask application using:
python app.py
-
Run the Flutter application using:
flutter run
-
Use the Flutter app to upload images and get similarity results from the Flask backend.