def predict(self, input_path=None, input_path_keras=None, input_data=None, weights_type='fine'):
    " Predict\n\n        Predict classes for test data\n\n        Parameters\n        ----------\n        input_path : str\n            Path to input data\n        input_path_keras : str\n            Path to input data in Keras format, i.e. path to directory one\n            level above where the data is stored\n        input_data : np.ndarray\n            Array of input images\n        weights_type : str, optional {'fine', 'top'}\n            Type of weights to use for predition, default is 'fine'\n\n        Returns\n        -------\n        dict\n            Dictionary of file names and corresponding classes\n\n        "
    if input_path:
        test_path = '/'.join(input_path.split('/')[:(- 1)])
    elif input_path_keras:
        test_path = input_path_keras
    else:
        test_path = None
    if (weights_type not in ('fine', 'top')):
        raise ValueError('Invalid value for weights_type. Options are "fine" or "top"')
    if test_path:
        self._get_target_shape(self._format(test_path, os.listdir(test_path)[0]))
        if (weights_type == 'fine'):
            model = self._build_final_model(load_final_weights=True)
        elif (weights_type == 'top'):
            model = self._build_final_model(load_top_weights=True)
        test_gen = self._load_generator(test_path, class_mode='categorical', batch_size=1)
        self.filenames = test_gen.filenames
        test_gen.reset()
        res = model.predict_generator(test_gen, verbose=self._verbose, steps=test_gen.steps).flatten()
    elif (not isinstance(input_data, type(None))):
        self._image_shape = input_data.shape[1:]
        self._get_target_shape()
        model = self._build_final_model(load_final_weights=True)
        res = model.predict(input_data, verbose=self._verbose).flatten()
    else:
        raise RuntimeError('No input data provided.')
    labels = {0: self._classes[0], 1: self._classes[1]}
    preds = [labels[k] for k in np.around(res)]
    return preds
Predict

Predict classes for test data

Parameters
----------
input_path : str
    Path to input data
input_path_keras : str
    Path to input data in Keras format, i.e. path to directory one
    level above where the data is stored
input_data : np.ndarray
    Array of input images
weights_type : str, optional {'fine', 'top'}
    Type of weights to use for predition, default is 'fine'

Returns
-------
dict
    Dictionary of file names and corresponding classes
def predict(self, input_path=None, input_path_keras=None, input_data=None, weights_type='fine'):
    " Predict\n\n        Predict classes for test data\n\n        Parameters\n        ----------\n        input_path : str\n            Path to input data\n        input_path_keras : str\n            Path to input data in Keras format, i.e. path to directory one\n            level above where the data is stored\n        input_data : np.ndarray\n            Array of input images\n        weights_type : str, optional {'fine', 'top'}\n            Type of weights to use for predition, default is 'fine'\n\n        Returns\n        -------\n        dict\n            Dictionary of file names and corresponding classes\n\n        "
    if input_path:
        test_path = '/'.join(input_path.split('/')[:(- 1)])
    elif input_path_keras:
        test_path = input_path_keras
    else:
        test_path = None
    if (weights_type not in ('fine', 'top')):
        raise ValueError('Invalid value for weights_type. Options are "fine" or "top"')
    if test_path:
        self._get_target_shape(self._format(test_path, os.listdir(test_path)[0]))
        if (weights_type == 'fine'):
            model = self._build_final_model(load_final_weights=True)
        elif (weights_type == 'top'):
            model = self._build_final_model(load_top_weights=True)
        test_gen = self._load_generator(test_path, class_mode='categorical', batch_size=1)
        self.filenames = test_gen.filenames
        test_gen.reset()
        res = model.predict_generator(test_gen, verbose=self._verbose, steps=test_gen.steps).flatten()
    elif (not isinstance(input_data, type(None))):
        self._image_shape = input_data.shape[1:]
        self._get_target_shape()
        model = self._build_final_model(load_final_weights=True)
        res = model.predict(input_data, verbose=self._verbose).flatten()
    else:
        raise RuntimeError('No input data provided.')
    labels = {0: self._classes[0], 1: self._classes[1]}
    preds = [labels[k] for k in np.around(res)]
    return preds