Image classification
Predicting among the original ImageNet categories with pretrained parameters.
Keras · Class
InceptionV3 builds the Inception v3 image-classification architecture, optionally initialized with ImageNet weights. Exclude its classifier and optionally pool the output to use it as a feature extractor.
InceptionV3 constructs the Keras implementation of the Inception v3 image-classification architecture. It can load ImageNet weights, retain or remove its classification head, and optionally apply global pooling to produce feature vectors; inputs should first pass through the matching preprocessing function.
keras.applications.InceptionV3(include_top=True, weights="imagenet", input_tensor=None, input_shape=None, pooling=None, classes=1000, classifier_activation="softmax", name="inception_v3")| Name | Type | Description |
|---|---|---|
include_top | Boolean | Whether to include the final fully connected classification layer; defaults to True. |
weights | None, string, or path | None for random initialization, "imagenet" for pretrained weights, or a weights-file path; defaults to "imagenet". |
input_tensor | Keras tensor or None | Optional Keras input tensor to use as the model input; defaults to None. |
input_shape | tuple or None | Optional three-channel input shape when include_top=False; defaults to None. |
pooling | string or None | Optional pooling mode for the feature output when the top is excluded; defaults to None. |
classes | integer | Number of output classes when the top is included and no weights are specified; defaults to 1000. |
classifier_activation | string or None | Activation for the classifier output; defaults to "softmax". |
name | string | Model name; defaults to "inception_v3". |
A Keras model instance for image classification, optionally initialized with ImageNet-pretrained weights.
keras.applications.InceptionV3() creates the Inception v3 network.weights accepts None, the ImageNet identifier, or a path to a weight file.include_top controls whether the final classifier is part of the returned model.import keras
model = keras.applications.InceptionV3(
weights="imagenet",
include_top=False,
pooling="avg",
input_shape=(299, 299, 3),
)
inputs = keras.Input((299, 299, 3))
x = keras.applications.inception_v3.preprocess_input(inputs)
features = model(x)
feature_model = keras.Model(inputs, features)Builds an ImageNet-backed InceptionV3 feature extractor and applies the model-specific pixel scaling before inference.
Predicting among the original ImageNet categories with pretrained parameters.
Generating compact representations for downstream vision models.
Replacing the original classifier with a task-specific output layer.
weights="imagenet" provide? The model is initialized with weights pretrained on ImageNet, rather than random values or weights loaded from a supplied file path.question is InceptionV3 limited to ImageNet classification?
Follow-up: How would you adapt it for a new label set? Use include_top=False, select a pooling strategy such as avg, and attach a new classifier.
include_top?The constructor returns a Keras image-classification model. Removing the top produces a backbone suitable for feature extraction, while pooling can turn spatial outputs into a fixed-size representation.
Follow-up: What does pooling="avg" do conceptually? It applies global average pooling to the final convolutional feature map.
InceptionV3 expects model-specific preprocessing before inference. Its preprocessing scales pixel values between -1 and 1.
Follow-up: Can preprocessing be placed inside the model graph? Yes; apply keras.applications.inception_v3.preprocess_input to the input tensor before calling the InceptionV3 model.
keras.applications.inception_v3.preprocess_inputkeras.applications.inception_v3.decode_predictionskeras.applications.InceptionResNetV2keras.applications.Xception