This guide will help you set up the Flask Face Recognition application from start to finish.
Download or clone the project to your local machine:
git clone https://github.com/Fliw/facerecogFlask
cd facerecogFlask
Set up a Python virtual environment for the project:
python3 -m venv venv
source venv/bin/activate # For Linux/Mac
venv\Scripts\activate # For Windows
Install all the required Python packages:
pip install -r requirements.txt
Create a .env
file in the root directory of the project and add the following configurations:
MYSQL_HOST=localhost
MYSQL_USER=xxx
MYSQL_PASSWORD=xxx
MYSQL_DB=xxx
MYSQL_PORT=3306
MYSQL_UNIX_SOCKET=xxxx
Ensure that MySQL is running and create the required database:
-
Log into MySQL:
mysql -u root -p
-
Create the database:
CREATE DATABASE facerecogDB;
-
Grant privileges to the database user (if necessary):
GRANT ALL PRIVILEGES ON facerecogDB.* TO 'root'@'localhost'; FLUSH PRIVILEGES;
-
(Optional) Verify the database exists:
SHOW DATABASES;
-
Don't Forget to Import the DB from facerecogDB.sql
Start the Flask development server:
python app.py
The server will start at http://127.0.0.1:5000
.
Visit the /test_db
endpoint to verify the database connection:
http://127.0.0.1:5000/test_db
You should see a JSON response with a list of available databases.
Use the application for:
- User registration (e.g.,
/register
) - Face recognition endpoints
If you encounter errors:
- Check the
.env
file for correct configurations. - Ensure MySQL is running:
sudo /opt/lampp/lampp startmysql
- Check for missing dependencies:
pip install -r requirements.txt
- Review the logs in the console for detailed error messages.