                        for k, v in retval.items()})
          return retval
  
      @staticmethod
      def _separate_target_mask(batch):
          """ Return the batch and the batch of final masks
  
          Returns the targets as a list of 4-dimensional ``numpy.ndarray`` s of shape (`batchsize`,
          `height`, `width`, 3). If the :attr:`batch` is 4 channels, then the masks will be split
          from the batch, with the largest output masks being returned in their own item.
 
</s> remove         batch = [tgt.astype("float32") / 255.0 for tgt in batch]
        if all(tgt.shape[-1] == 4 for tgt in batch):
            logger.trace("Batch contains mask")
            sizes = [item.shape[1] for item in batch]
            mask_batch = np.expand_dims(batch[sizes.index(max(sizes))][..., -1], axis=-1)
            batch = [item[..., :3] for item in batch]
            logger.trace("batch shapes: %s, mask_batch shape: %s",
                         [tgt.shape for tgt in batch], mask_batch.shape)
            retval = dict(targets=batch, masks=mask_batch)
 </s> add         targets = [batch[..., :3] for batch in size_list_of_batches]
        if size_list_of_batches[-1].shape[-1] == 4:
            masks = [size_list_of_batches[-1][..., 3:]] </s> remove             the format (`batchsize`, `height`, `width`, `1`). **NB:** This item will only exist \
            in the ``dict`` if a batch of 4 channel images has been passed in :attr:`batch`
 </s> add             the format (`batchsize`, `height`, `width`, `1`). </s> remove             the format (`batchsize`, `height`, `width`, `1`). **NB:** This item will only exist \
            in the ``dict`` if the :attr:`mask_type` is not ``None``
 </s> add             the format (`batchsize`, `height`, `width`, `1`). </s> remove #!/usr/bin/env python3
""" Plugin loader for extract, training and model tasks """

import logging
import os
from importlib import import_module

logger = logging.getLogger(__name__)  # pylint: disable=invalid-name


class PluginLoader():
    """ Plugin loader for extract, training and model tasks """
    @staticmethod
    def get_detector(name, disable_logging=False):
        """ Return requested detector plugin """
        return PluginLoader._import("extract.detect", name, disable_logging)

    @staticmethod
    def get_aligner(name, disable_logging=False):
        """ Return requested detector plugin """
        return PluginLoader._import("extract.align", name, disable_logging)

    @staticmethod
    def get_model(name, disable_logging=False):
        """ Return requested model plugin """
        return PluginLoader._import("train.model", name, disable_logging)

    @staticmethod
    def get_trainer(name, disable_logging=False):
        """ Return requested trainer plugin """
        return PluginLoader._import("train.trainer", name, disable_logging)

    @staticmethod
    def get_converter(category, name, disable_logging=False):
        """ Return the converter sub plugin """
        return PluginLoader._import("convert.{}".format(category), name, disable_logging)

    @staticmethod
    def _import(attr, name, disable_logging):
        """ Import the plugin's module """
        name = name.replace("-", "_")
        ttl = attr.split(".")[-1].title()
        if not disable_logging:
            logger.info("Loading %s from %s plugin...", ttl, name.title())
        attr = "model" if attr == "Trainer" else attr.lower()
        mod = ".".join(("plugins", attr, name))
        module = import_module(mod)
        return getattr(module, ttl)

    @staticmethod
    def get_available_extractors(extractor_type):
        """ Return a list of available aligners/detectors """
        extractpath = os.path.join(os.path.dirname(__file__),
                                   "extract",
                                   extractor_type)
        extractors = sorted(item.name.replace(".py", "").replace("_", "-")
                            for item in os.scandir(extractpath)
                            if not item.name.startswith("_")
                            and not item.name.endswith("defaults.py")
                            and item.name.endswith(".py")
                            and item.name != "manual.py")
        return extractors

    @staticmethod
    def get_available_models():
        """ Return a list of available models """
        modelpath = os.path.join(os.path.dirname(__file__), "train", "model")
        models = sorted(item.name.replace(".py", "").replace("_", "-")
                        for item in os.scandir(modelpath)
                        if not item.name.startswith("_")
                        and not item.name.endswith("defaults.py")
                        and item.name.endswith(".py"))
        return models

    @staticmethod
    def get_default_model():
        """ Return the default model """
        models = PluginLoader.get_available_models()
        return 'original' if 'original' in models else models[0]

    @staticmethod
    def get_available_convert_plugins(convert_category, add_none=True):
        """ Return a list of available models """
        convertpath = os.path.join(os.path.dirname(__file__),
                                   "convert",
                                   convert_category)
        converters = sorted(item.name.replace(".py", "").replace("_", "-")
                            for item in os.scandir(convertpath)
                            if not item.name.startswith("_")
                            and not item.name.endswith("defaults.py")
                            and item.name.endswith(".py"))
        if add_none:
            converters.insert(0, "none")
        return converters
 </s> add #!/usr/bin/env python3
""" Plugin loader for extract, training and model tasks """

import logging
import os
from importlib import import_module

logger = logging.getLogger(__name__)  # pylint: disable=invalid-name


class PluginLoader():
    """ Plugin loader for extract, training and model tasks """
    @staticmethod
    def get_detector(name, disable_logging=False):
        """ Return requested detector plugin """
        return PluginLoader._import("extract.detect", name, disable_logging)

    @staticmethod
    def get_aligner(name, disable_logging=False):
        """ Return requested detector plugin """
        return PluginLoader._import("extract.align", name, disable_logging)

    @staticmethod
    def get_masker(name, disable_logging=False):
        """ Return requested detector plugin """
        return PluginLoader._import("extract.mask", name, disable_logging)

    @staticmethod
    def get_model(name, disable_logging=False):
        """ Return requested model plugin """
        return PluginLoader._import("train.model", name, disable_logging)

    @staticmethod
    def get_trainer(name, disable_logging=False):
        """ Return requested trainer plugin """
        return PluginLoader._import("train.trainer", name, disable_logging)

    @staticmethod
    def get_converter(category, name, disable_logging=False):
        """ Return the converter sub plugin """
        return PluginLoader._import("convert.{}".format(category), name, disable_logging)

    @staticmethod
    def _import(attr, name, disable_logging):
        """ Import the plugin's module """
        name = name.replace("-", "_")
        ttl = attr.split(".")[-1].title()
        if not disable_logging:
            logger.info("Loading %s from %s plugin...", ttl, name.title())
        attr = "model" if attr == "Trainer" else attr.lower()
        mod = ".".join(("plugins", attr, name))
        module = import_module(mod)
        return getattr(module, ttl)

    @staticmethod
    def get_available_extractors(extractor_type):
        """ Return a list of available aligners/detectors """
        extractpath = os.path.join(os.path.dirname(__file__),
                                   "extract",
                                   extractor_type)
        extractors = sorted(item.name.replace(".py", "").replace("_", "-")
                            for item in os.scandir(extractpath)
                            if not item.name.startswith("_")
                            and not item.name.endswith("defaults.py")
                            and item.name.endswith(".py")
                            and item.name != "manual.py")
        return extractors

    @staticmethod
    def get_available_models():
        """ Return a list of available models """
        modelpath = os.path.join(os.path.dirname(__file__), "train", "model")
        models = sorted(item.name.replace(".py", "").replace("_", "-")
                        for item in os.scandir(modelpath)
                        if not item.name.startswith("_")
                        and not item.name.endswith("defaults.py")
                        and item.name.endswith(".py"))
        return models

    @staticmethod
    def get_default_model():
        """ Return the default model """
        models = PluginLoader.get_available_models()
        return 'original' if 'original' in models else models[0]

    @staticmethod
    def get_available_convert_plugins(convert_category, add_none=True):
        """ Return a list of available models """
        convertpath = os.path.join(os.path.dirname(__file__),
                                   "convert",
                                   convert_category)
        converters = sorted(item.name.replace(".py", "").replace("_", "-")
                            for item in os.scandir(convertpath)
                            if not item.name.startswith("_")
                            and not item.name.endswith("defaults.py")
                            and item.name.endswith(".py"))
        if add_none:
            converters.insert(0, "none")
        return converters </s> remove         align_eyes: bool, optional
            Optionally perform additional alignment to align eyes. Default: `False`
 </s> add         coverage_ratio: float
            The metric determining the field of view of the returned face
    def _separate_target_mask(size_list_of_batches):
                        for k, v in retval.items()})
          return retval
  
      @staticmethod
    def _separate_target_mask(size_list_of_batches):
          """ Return the batch and the batch of final masks
  
          Returns the targets as a list of 4-dimensional ``numpy.ndarray`` s of shape (`batchsize`,
          `height`, `width`, 3). If the :attr:`batch` is 4 channels, then the masks will be split
          from the batch, with the largest output masks being returned in their own item.
keep keep keep keep replace keep keep keep keep keep
 Smart Mask Exposure for Extraction & Training (#831)

Smart Masks - Initial Commit 
lib/training_data.py