import numpy as np
import tensorflow as tf


def map_generator(image, model_path):
    """
    Localization map generator.

    Parameters
    ----------
    image : numpy.ndarray
    model_path : string
        path to a tensorflow model to be used

    Returns
    -------
    localization_map : numpy.ndarray
    """

    if image.ndim == 2:
        image = np.reshape(image, image.shape + (1,))

    # normalize value to range from 0 to 1
    image = image / 255

    # add 0th dimension needed by tensorflow
    image = np.expand_dims(image, axis=0)

    model = tf.keras.models.load_model(model_path)

    return model.predict(image, verbose=0)[0]
