This project is a deep learning-based image classification system built with TensorFlow and Keras. It classifies images into two categories: "happy" and "sad". The workflow includes data preprocessing, model training, evaluation, and prediction.
├── data/
│ ├── happy/
│ └── sad/
├── logs/
│ ├── train/
│ └── validation/
├── models/
│ └── imageclassifier.h5
├── notebook.ipynb
├── requirements.txt
└── venv311/
- data/: Contains subfolders for each class ("happy", "sad") with images for training and validation.
- logs/: Stores TensorBoard logs for training and validation.
- models/: Contains the saved Keras model.
- notebook.ipynb: Jupyter notebook with step-by-step code for data processing, model building, training, evaluation, and testing.
- requirements.txt: List of required Python packages.
- venv311/: Python virtual environment.
- Install Dependencies
- TensorFlow, OpenCV, Matplotlib, and other required packages.
- Data Cleaning
- Remove corrupted or unsupported images.
- Data Loading & Preprocessing
- Load images using
tf.keras.utils.image_dataset_from_directory. - Scale pixel values to [0, 1].
- Split data into training, validation, and test sets.
- Load images using
- Model Building
- Build a CNN using Keras Sequential API.
- Training
- Train the model with TensorBoard logging.
- Evaluation
- Evaluate model performance using accuracy, precision, and recall.
- Testing
- Test the model on new images.
- Saving & Loading Model
- Save the trained model and demonstrate loading for inference.
- Clone the repository and navigate to the project directory.
- (Optional) Create and activate a Python virtual environment.
- Install dependencies:
pip install -r requirements.txt
- Place your images in the
data/happy/anddata/sad/folders. - Open and run the
Getting Started.ipynbnotebook to train and test the model.
- Python 3.11+
- TensorFlow
- OpenCV
- Matplotlib
- NumPy
All dependencies are listed in requirements.txt.
- The model is a simple CNN with Conv2D, MaxPooling2D, Flatten, and Dense layers.
- Trained model is saved as
models/imageclassifier.h5.
- Training and validation logs are saved in the
logs/directory for visualization with TensorBoard.
This project is for educational purposes.