Skip to content

AtharvaBelgamwar/ML-hackathon-PS_2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

Face Age Prediction

This repository contains Python code to perform face age prediction using a Convolutional Neural Network (CNN). The code includes data preprocessing, model building, training, and prediction steps. It's designed to work with a dataset of face images organized into age groups.

Table of Contents

Getting Started

Prerequisites

Before running the code, make sure you have the following prerequisites installed:

  • Python (>=3.6)
  • Jupyter Notebook (optional for running code interactively)
  • Required Python libraries (install with pip as mentioned in the code)

Installation

  1. Clone this repository to your local machine:

    git clone https://github.com/yourusername/face-age-prediction.git
    
  2. Navigate to the project directory:

    cd face-age-prediction
    
  3. Install the required Python libraries::

    pip install -r requirements.txt
    

Usage

Data Preparation

  1. Download the face age dataset in a ZIP file format and place it in a directory.

  2. Update the zip_file_path variable in the code with the correct path to your ZIP file.

  3. Run the code to extract the dataset and preprocess the images.

Model Training

  1. Define and compile the CNN model in the code according to your requirements.

  2. Run the code to train the model using the preprocessed data.

Model Evaluation

  1. After training, evaluate the model on the test set and print evaluation results such as loss, Mean Absolute Error (MAE), and Mean Squared Error (MSE).

Age Prediction

  1. Use the trained model to make age predictions for new images. Provide the path to the image in the code, and it will predict the age.

Customization

You can customize the code and model architecture according to your specific dataset and requirements. Here are some ways to customize the project:

  1. Model Architecture: Adjust the CNN layers and their hyperparameters in the code to fine-tune the model's performance.

  2. Preprocessing: Modify the preprocessing steps to suit the characteristics of your dataset. You can change image resizing, color transformations, or normalization techniques.

  3. Data Augmentation: If needed, add data augmentation techniques using libraries like Keras ImageDataGenerator to improve model generalization.

  4. Batching and Shuffling: Handle batching and shuffling according to your dataset's size and distribution. You can fine-tune batch sizes and shuffling strategies during model training.

Feel free to experiment and adapt the code to best fit your specific use case. Customization allows you to tailor the solution to the unique characteristics of your face age prediction dataset.

Contributing

If you'd like to contribute to this project, please follow the standard GitHub flow:

  1. Fork the repository: Click the "Fork" button on the top right corner of this repository's page to create your own fork.

  2. Create a new branch: Create a new branch for your feature or bug fix. Use a descriptive name for your branch, like feature-name or bugfix-description.

  3. Make changes and commit them: Implement your changes, add new features, or fix issues. Ensure that your code follows the project's coding guidelines. Commit your work with clear and concise commit messages.

  4. Push your changes to your fork: Push your branch to your fork on GitHub.

  5. Open a pull request: Go to the original repository on GitHub, and click on the "New Pull Request" button. Select your branch as the source and describe your changes in the pull request.

Your contribution will be reviewed, and if everything looks good, it will be merged into the main project.

Thank you for contributing to this project! Your contributions help make this project better for everyone.

Model Performance

After training, you can evaluate the model's performance on the test set and calculate its accuracy.

test_loss, test_mae, test_mse = model.evaluate(X_test, y_test)

threshold = 5
correct_predictions = sum(1 for i in range(len(predictions)) if abs(predictions[i] - y_test[i]) <= threshold)
accuracy = correct_predictions / len(predictions) * 100

print(f'Test Loss: {test_loss}')
print(f'Mean Absolute Error (MAE): {test_mae}')
print(f'Mean Squared Error (RMSE): {test_mse}')
print(f'Accuracy (within {threshold} years): {accuracy:.2f}%')




About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors