Image Classification
KerasHub
Edit model card

Model Overview

The VGG model is a type of convolutional neural network (CNN) architecture designed for image recognition and classification tasks. Developed by the Visual Geometry Group at the University of Oxford, it was introduced in the paper titled "Very Deep Convolutional Networks for Large-Scale Image Recognition" by Karen Simonyan and Andrew Zisserman in 2014. This model is supported in both KerasCV and KerasHub. KerasCV will no longer be actively developed, so please try to use KerasHub.

Links

Installation

Keras and KerasHub can be installed with:

pip install -U -q keras-Hub
pip install -U -q keras>=3

Jax, TensorFlow, and Torch come preinstalled in Kaggle Notebooks. For instructions on installing them in another environment see the Keras Getting Started page.

Presets

The following model checkpoints are provided by the Keras team. Weights have been ported from https://huggingface.co/timm.

Preset Name Parameters Description
vgg_11_imagenet 9.22M 11-layer VGG model pre-trained on the ImageNet 1k dataset at a 224x224 resolution.
vgg_13_imagenet 9.40M 13-layer VGG model pre-trained on the ImageNet 1k dataset at a 224x224 resolution.
vgg_16_imagenet 14.71M 16-layer VGG model pre-trained on the ImageNet 1k dataset at a 224x224 resolution.
vgg_19_imagenet 20.02M 19-layer VGG model pre-trained on the ImageNet 1k dataset at a 224x224 resolution.

Example Usage

input_data = np.ones(shape=(2, 224, 224, 3))

# Pretrained backbone
model = keras_hub.models.VGGBackbone.from_preset("vgg_16_imagenet")
model(input_data)

# Randomly initialized backbone with a custom config
model = keras_hub.models.VGGBackbone(
    stackwise_num_repeats=[2, 3, 3, 2],
    stackwise_num_filters=[64, 128, 256, 512],
)
model(input_data)

# Use VGG for image classification task
model = keras_hub.models.ImageClassifier.from_preset("vgg_16_imagenet")

# User Timm presets directly from HuggingFace
model = keras_hub.models.ImageClassifier.from_preset('hf://timm/vgg11.tv_in1k')

Example Usage with Hugging Face URI

input_data = np.ones(shape=(2, 224, 224, 3))

# Pretrained backbone
model = keras_hub.models.VGGBackbone.from_preset("hf://keras/vgg_16_imagenet")
model(input_data)

# Randomly initialized backbone with a custom config
model = keras_hub.models.VGGBackbone(
    stackwise_num_repeats=[2, 3, 3, 2],
    stackwise_num_filters=[64, 128, 256, 512],
)
model(input_data)

# Use VGG for image classification task
model = keras_hub.models.ImageClassifier.from_preset("hf://keras/vgg_16_imagenet")

# User Timm presets directly from HuggingFace
model = keras_hub.models.ImageClassifier.from_preset('hf://timm/vgg11.tv_in1k')
Downloads last month
25
Inference Examples
Inference API (serverless) does not yet support keras-hub models for this pipeline type.

Collection including keras/vgg_16_imagenet