# Path: keras_image_captioning/config.py
# def active_config(new_active_config=None):
#     if new_active_config:
#         global _active_config
#         _active_config = new_active_config
#     return _active_config


import numpy as np
from functools import partial
from keras.applications import inception_v3
from keras.preprocessing import sequence as keras_seq
from keras.preprocessing.image import (ImageDataGenerator, img_to_array,
                                       load_img)
from keras.preprocessing.text import Tokenizer, text_to_word_sequence
from .config import active_config
                   img_paths)

    def preprocess_batch(self, img_list):
        return np.array(img_list)

    def _preprocess_an_image(self, img_path, random_transform=True):
        img = load_img(img_path, target_size=self.IMAGE_SIZE)
        img_array = img_to_array(img)
        if self._image_augmentation_switch and random_transform:
            img_array = self._image_data_generator.random_transform(img_array)
        img_array = inception_v3.preprocess_input(img_array)

        return img_array


class CaptionPreprocessor(object):
    """Preprocesses captions before feeded into the network."""

    EOS_TOKEN = 'zeosz'

    def __init__(self, rare_words_handling=None, words_min_occur=None):
        """
        If an arg is None, it will get its value from config.active_config.
        Args:
          rare_words_handling: {'nothing'|'discard'|'change'}
          words_min_occur: words whose occurrences are less than this are
                           considered rare words
        """
        self._tokenizer = Tokenizer()
        self._rare_words_handling = (rare_words_handling or

# Path: keras_image_captioning/config.py
# def active_config(new_active_config=None):
#     if new_active_config:
#         global _active_config
#         _active_config = new_active_config
#     return _active_config


# Path: keras_image_captioning/preprocessors.py
import numpy as np
from functools import partial
from keras.applications import inception_v3
from keras.preprocessing import sequence as keras_seq
from keras.preprocessing.image import (ImageDataGenerator, img_to_array,
                                       load_img)
from keras.preprocessing.text import Tokenizer, text_to_word_sequence
from .config import active_config

                   img_paths)

    def preprocess_batch(self, img_list):
        return np.array(img_list)

    def _preprocess_an_image(self, img_path, random_transform=True):
        img = load_img(img_path, target_size=self.IMAGE_SIZE)
        img_array = img_to_array(img)
        if self._image_augmentation_switch and random_transform:
            img_array = self._image_data_generator.random_transform(img_array)
        img_array = inception_v3.preprocess_input(img_array)

        return img_array


class CaptionPreprocessor(object):
    """Preprocesses captions before feeded into the network."""

    EOS_TOKEN = 'zeosz'

    def __init__(self, rare_words_handling=None, words_min_occur=None):
        """
        If an arg is None, it will get its value from config.active_config.
        Args:
          rare_words_handling: {'nothing'|'discard'|'change'}
          words_min_occur: words whose occurrences are less than this are
                           considered rare words
        """
        self._tokenizer = Tokenizer()
        self._rare_words_handling = (rare_words_handling or

                                     active_config().rare_words_handling)