Athlete Classification with Open CV

Table of Contents
  1. Project Description
  2. Data Exploration
  3. Face detection
  4. Wavelet Transform
  5. Results and discussion
  6. Confusion matrix for best model
  7. License
  8. Contact
  9. References

Project Description

The purpose of this project is to perform classification of famous athletes with the use of OpenCV. We have made use of two seperate datasets, both of which contained 5 athletes to be classified. The first one was supplied from Dhaval Patel [1], from whom we also got the inspiration to do the project. The second dataset was obtained with the help of web scraping. The classifiers used to perform the classification were Support Vector Machines, Random Forrest and Logistic Regression, all with the help of GridSearchCV, such as to be able to find the best hyper parameters.

The first step after obtaining the data was to crop the face of each athlete and use those cropped images for the training of our classifiers, since the face is the main part used to differentiate the athletes from each other. In order to detect the faces, we have made use of the OpenCV Haar Cascades xml files, which act themselves as a classifier. Once the faces cropped, we use wavelet transform to create a new image from the cropped image in order to highlight the essential features of the face. Since the original image also contains important features, we stack both the original image and the one obtained from applying the wavelet transform and feed it as input to the classifiers.

Our results show that we obtained much better results with the first dataset, i.e the one already provided to us. We believe that the reason for this has to do with the quality between the two datasets. The first dataset simply had better resolution, which resulted in more useful information being conveyed in the image.

(back to top)

Data Exploration

Dataset 1 Histogram

alt text

Dataset 2 Histogram

alt text

Face detection

alt text      alt text      alt text
alt text      alt text      alt text

(back to top)

Wavelet Transform

Once the images were cropped, we made use of the wavelet transform in order to extract the important features of the face. The main idea of the wavelet transform is the ability to capture both local spectral and temporal information. More information about it can be found here [2].

alt text      alt text
alt text      alt text

(back to top)

Results and discussion

Dataset 1

Classifier Testing Accuracy
SVM 0.914
Random Forest 0.723
Logistic Regression 0.894

Dataset 2

Classifier Testing Accuracy
SVM 0.545
Random Forest 0.455
Logistic Regression 0.515

From the results obtained above, we can see that SVM performed the best for both datasets. We clearly see a much better performance on the first dataset however, and we believe this is due to the better resolution of the images used, which allowed for more features to be captured. Additionally, we made use of GridSearchCV in order to try and find the best hyperparameters for our models.

(back to top)

Confusion matrix for best model

alt text

Contact

Robert Rey - LinkedIn

Project Link: Athlete Classification

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

References

[1] Dhaval Patel, https://codebasics.io/

[2] The Wavelet Transform, Shawhin Talebi, https://towardsdatascience.com/the-wavelet-transform-e9cfa85d7b34

(back to top)