This Flask application detects faces in uploaded images, blurs the faces, and overlays sunglasses on them. It utilizes MTCNN for face detection, OpenCV for image processing, and PIL (Python Imaging Library) for image manipulation.
- Python 3.6 or later
- pip
-
Clone the repository
git clone <repository-url> cd <repository-name>
-
Set up a virtual environment (optional but recommended)
-
For Unix/macOS:
python3 -m venv venv source venv/bin/activate
-
For Windows:
python -m venv venv .\venv\Scripts\activate
-
-
Install the required dependencies
pip install -r requirements.txt
-
TensorFlow Installation Note
The project uses MTCNN, which depends on TensorFlow. The
requirements.txt
includes the CPU version of TensorFlow. If you need TensorFlow with GPU support, please installtensorflow-gpu
instead by running:pip install tensorflow-gpu==2.6.0
-
Start the Flask application
python app.py
The application will start running on
http://localhost:5000
. -
Using the application
- The application provides an endpoint
/process-image
which expects a POST request with an image file. - You can use Postman or any other API testing tool to send a request to this endpoint.
- Postman collection have been included so make sure to attach an image while calling this endpoint
- Since this is running locally a postman desktop agent is preferred
- The application provides an endpoint
-
Postman Collection
- A Postman collection is included in the root folder of the project (
Update_Image.json
). Import this collection into Postman to easily test the application. - Make sure to attach the image you want to process with the request under the form-data section with the key
image
. - The image is already present in the folder were the postman collection is present and the output of the processed image "update_image.png" is present at the project root
- A Postman collection is included in the root folder of the project (
POST /process-image
- Description: Processes the uploaded image, detects faces, blurs them, and overlays sunglasses.
- Body:
multipart/form-data
with a key ofimage
and the value being the file you wish to upload.