Ejemplo n.º 1
0
def preprocess_input(x, **kwargs):
    kwargs = {
        k: v
        for k, v in kwargs.items()
        if k in ['backend', 'layers', 'models', 'utils']
    }
    return _preprocess_input(x, mode='torch', **kwargs)
def preprocess_input(x):
    """
    "mode" option description in preprocess_input
    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.
    """
    x = _preprocess_input(x, mode='tf', backend=K)
    #x /= 255.
    #mean = [0.485, 0.456, 0.406]
    #std = [0.229, 0.224, 0.225]

    #x[..., 0] -= mean[0]
    #x[..., 1] -= mean[1]
    #x[..., 2] -= mean[2]
    #if std is not None:
    #x[..., 0] /= std[0]
    #x[..., 1] /= std[1]
    #x[..., 2] /= std[2]

    return x
def preprocess_input(x, **kwargs):
    kwargs = {
        k: v
        for k, v in kwargs.items()
        if k in ["backend", "layers", "models", "utils"]
    }
    return _preprocess_input(x, mode="torch", **kwargs)
def preprocess_input(x, **kwargs):
    """Preprocesses a numpy array encoding a batch of images.

    # Arguments
        x: a 4D numpy array consists of RGB values within [0, 255].

    # Returns
        Preprocessed array.
    """
    return _preprocess_input(x, mode='tf', backend=K, **kwargs)
Ejemplo n.º 5
0
def preprocess_input(x):
    """
    "mode" option description in preprocess_input
    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.
    """
    x = _preprocess_input(x, mode='tf', backend=K)
    return x
Ejemplo n.º 6
0
def preprocess_input(x, **kwargs):
    return _preprocess_input(x, mode='torch', **kwargs)