Functions | |
| def | _preprocess_numpy_input (x, data_format, mode) |
| def | _preprocess_symbolic_input (x, data_format, mode) |
| def | preprocess_input (x, data_format=None, mode='caffe') |
| def | decode_predictions (preds, top=5) |
| def | _obtain_input_shape (input_shape, default_size, min_size, data_format, require_flatten, weights=None) |
Variables | |
| CLASS_INDEX = None | |
| string | CLASS_INDEX_PATH = 'https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json' |
| _IMAGENET_MEAN = None | |
Utilities for ImageNet data preprocessing & prediction decoding.
|
private |
Internal utility to compute/validate a model's input shape.
# Arguments
input_shape: Either None (will return the default network input shape),
or a user-provided shape to be validated.
default_size: Default input width/height for the model.
min_size: Minimum input width/height accepted by the model.
data_format: Image data format to use.
require_flatten: Whether the model is expected to
be linked to a classifier via a Flatten layer.
weights: One of `None` (random initialization)
or 'imagenet' (pre-training on ImageNet).
If weights='imagenet' input channels must be equal to 3.
# Returns
An integer shape tuple (may include None entries).
# Raises
ValueError: In case of invalid argument values.
Definition at line 233 of file imagenet_utils.py.
|
private |
Preprocesses a Numpy array encoding a batch of images.
# Arguments
x: Input array, 3D or 4D.
data_format: Data format of the image array.
mode: One of "caffe", "tf" or "torch".
- caffe: will convert the images from RGB to BGR,
then will zero-center each color channel with
respect to the ImageNet dataset,
without scaling.
- tf: will scale pixels between -1 and 1,
sample-wise.
- torch: will scale pixels between 0 and 1 and then
will normalize each channel with respect to the
ImageNet dataset.
# Returns
Preprocessed Numpy array.
Definition at line 21 of file imagenet_utils.py.
|
private |
Preprocesses a tensor encoding a batch of images.
# Arguments
x: Input tensor, 3D or 4D.
data_format: Data format of the image tensor.
mode: One of "caffe", "tf" or "torch".
- caffe: will convert the images from RGB to BGR,
then will zero-center each color channel with
respect to the ImageNet dataset,
without scaling.
- tf: will scale pixels between -1 and 1,
sample-wise.
- torch: will scale pixels between 0 and 1 and then
will normalize each channel with respect to the
ImageNet dataset.
# Returns
Preprocessed tensor.
Definition at line 95 of file imagenet_utils.py.
| def imagenet_utils.decode_predictions | ( | preds, | |
top = 5 |
|||
| ) |
Decodes the prediction of an ImageNet model.
# Arguments
preds: Numpy tensor encoding a batch of predictions.
top: Integer, how many top-guesses to return.
# Returns
A list of lists of top class prediction tuples
`(class_name, class_description, score)`.
One list of tuples per sample in batch input.
# Raises
ValueError: In case of invalid shape of the `pred` array
(must be 2D).
Definition at line 190 of file imagenet_utils.py.
| def imagenet_utils.preprocess_input | ( | x, | |
data_format = None, |
|||
mode = 'caffe' |
|||
| ) |
Preprocesses a tensor or Numpy array encoding a batch of images.
# Arguments
x: Input Numpy or symbolic tensor, 3D or 4D.
The preprocessed data is written over the input data
if the data types are compatible. To avoid this
behaviour, `numpy.copy(x)` can be used.
data_format: Data format of the image tensor/array.
mode: One of "caffe", "tf" or "torch".
- caffe: will convert the images from RGB to BGR,
then will zero-center each color channel with
respect to the ImageNet dataset,
without scaling.
- tf: will scale pixels between -1 and 1,
sample-wise.
- torch: will scale pixels between 0 and 1 and then
will normalize each channel with respect to the
ImageNet dataset.
# Returns
Preprocessed tensor or Numpy array.
# Raises
ValueError: In case of unknown `data_format` argument.
Definition at line 152 of file imagenet_utils.py.
|
private |
Definition at line 18 of file imagenet_utils.py.
| imagenet_utils.CLASS_INDEX = None |
Definition at line 14 of file imagenet_utils.py.
| string imagenet_utils.CLASS_INDEX_PATH = 'https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json' |
Definition at line 15 of file imagenet_utils.py.
1.8.11