A deep learning project that demonstrates image classification using a pre-trained VGG16 model with Keras and TensorFlow. The model can classify images into 1,000 different categories using the ImageNet dataset.
This project uses the VGG16 convolutional neural network architecture, pre-trained on the ImageNet dataset, to classify various images. The model achieves high accuracy on a wide range of object categories.
- Pre-trained VGG16 model for image classification
- Support for 1,000 ImageNet categories
- Visual probability distribution for top 10 predictions
- Interactive Jupyter Notebook with example classifications
- Easy-to-use prediction function
- Python 3.6+
- Keras
- TensorFlow
- NumPy
- Pandas
- Matplotlib
- Seaborn
- Jupyter Notebook
See requirements.txt for detailed dependencies.
- Clone this repository:
git clone https://github.com/benstanbury/Image_Classification_Keras.git
cd Image_Classification_Keras- Install dependencies:
pip install -r requirements.txtNote: On first run, the model will download pre-trained weights (~500MB), which may take a few minutes.
Open and run the interactive notebook:
jupyter notebook Image_Classification_with_Keras.ipynbThe notebook includes examples of classifying various images including:
- Animals (cheetah)
- Objects (guitar)
- Complex scenes (self-driving car, multiple fruits)
- People
You can also use the VGG16 model directly in your Python code:
from keras.preprocessing import image as image_utils
from imagenet_utils import decode_predictions, preprocess_input
from vgg16 import VGG16
import numpy as np
# Load and preprocess image
img = image_utils.load_img('your_image.jpg', target_size=(224, 224))
img_array = image_utils.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0)
img_array = preprocess_input(img_array)
# Make prediction
model = VGG16(weights="imagenet")
predictions = model.predict(img_array)
results = decode_predictions(predictions, top=5)
print(results)Image_Classification_Keras/
├── Image_Classification_with_Keras.ipynb # Main interactive notebook
├── vgg16.py # VGG16 model implementation
├── imagenet_utils.py # ImageNet utilities and preprocessing
├── requirements.txt # Project dependencies
├── README.md # Project documentation
├── LICENSE # MIT License
├── *.jpg # Example images for classification
└── .gitignore # Git ignore rules
The VGG16 model is a deep convolutional neural network that consists of:
- 16 weight layers (13 convolutional + 3 fully connected)
- Input size: 224x224 RGB images
- Output: 1,000 class probabilities
- Pre-trained on ImageNet dataset
For more details, see the original paper: Very Deep Convolutional Networks for Large-Scale Image Recognition
The notebook demonstrates classification on several example images with visualization of the top 10 predictions and their probabilities.
This project was built using the following resources:
- PyImageSearch - ImageNet Classification with Python and Keras
- TensorFlow Tutorials by Hvass-Labs
- Keras Deep Learning Models
- ImageNet Dataset
- VGG16 Paper
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
Ben Stanbury
- Thanks to the Keras team for the excellent deep learning framework
- ImageNet for providing the comprehensive dataset
- The VGG team at Oxford for the model architecture