Skip to content

utkarshmalkoti/Face-Detection

Repository files navigation

Face Detection and Face Recognition with Keras

Goal

Scrape images from Goolge Images, Faces Detection using Haar Cascade, Face Recognition

Installations

- Install virtual env.
- Install Webdriver in the folder.
- Install Selenium.
- Install PIL.
- Install OpenCV.
- Install Numpy.
- Install Tensorflow and keras.
pip install virtualenv
pip install selenium
pip install pillow
pip install opencv-python
pip install tensorflow
pip install keras

Scrapping images from Google Images

- Open scraping.py.
- Run python script.
- Enter the list of Celebrities and to end the list enter -1.

This Python script will search 4 celebrities at a time and scrape them parallelly to save time and save all of the images in a folder with respective celebrity name.

Image Preprocessing

- Open hashing.py and run.
This program is made to remove duplicate images.

Face Detection

- Open python folder and copy 'data' folder and face it inside your folder.
- Open Face_detect.py and run.
This Python script will detect faces from dowloaded images, crop them and save in a folder named 'faces' inside respective celebrity folder with 100*100 resolution.
-> Now, run hashing.py just to be sure that there are no duplicate images.
-> Then, delete all the unwanted images or bad quality images from the 'faces' folder.

Data Augmentation

- Open and run data_aug.py.
This python script will increase the data set by changing some specifications of the current image dataset.

Dataset

-Open and run dataset.py.
This will convert images into numpy array and save them in a pickle file as 'x.pickle' and 'y.pickle'. Where 'x.pickle' contains numpy arrays of all the images and 'y.pickle' contains labels.

Face Recognition Model

- Open and run new.py.
This CNN model will split the dataset int training and testing dataset and train the model.

I have added my dataset as 'Xall.pickle' and 'Yall.pickle' and model as 'Cnn_model.json' and nuerons weights as 'best_new_weights.hdf5'.