          """ Train a batch """
          logger.trace("Training one step: (side: %s)", self.side)
          batch = self.get_next(do_preview)
          try:
              loss = self.model.predictors[self.side].train_on_batch(*batch)
          except tf_errors.ResourceExhaustedError as err:
              msg = ("You do not have enough GPU memory available to train the selected model at "
                     "the selected settings. You can try a number of things:"
                     "\n1) Close any other application that is using your GPU (web browsers are "
                     "particularly bad for this)."
 
</s> remove         batch = self.get_next(do_preview)
 </s> add         model_inputs, model_targets = self.get_next() </s> remove     def train_one_batch(self, do_preview):
 </s> add     def train_one_batch(self): </s> remove                    "\nIf you are training with a mask or using 'warp to landmarks' then every "
 </s> add                    "\nIf you are using 'warp to landmarks' then every " </s> remove     def _set__mask_class(self):
        """ Returns the correct mask class from :mod:`lib`.model.masks` as defined in the
        :attr:`mask_type` parameter. """
        mask_type = self._training_opts.get("mask_type", None)
        if mask_type:
            logger.debug("Mask type: '%s'", mask_type)
            _mask_class = getattr(masks, mask_type)
        else:
            _mask_class = None
        logger.debug("Mask class: %s", _mask_class)
        return _mask_class

 </s> add  </s> remove         argument_list.append({
            "opts": ("-D", "--detector"),
            "action": Radio,
            "type": str.lower,
            "choices":  PluginLoader.get_available_extractors("detect"),
            "default": default_detector,
            "group": "Plugins",
            "help": "R|Detector to use. Some of these have configurable settings in "
                    "'/config/extract.ini' or 'Settings > Configure Extract Plugins':"
                    "\nL|cv2-dnn: A CPU only extractor, is the least reliable, but uses least "
                    "resources and runs fast on CPU. Use this if not using a GPU and time is "
                    "important."
                    "\nL|mtcnn: Fast on CPU, Faster on GPU. Uses far fewer resources than other "
                    "GPU detectors but can often return more false positives."
                    "\nL|s3fd: Fast on GPU, slow on CPU. Can detect more faces and "
                    "fewer false positives than other GPU detectors, but is a lot more resource "
                    "intensive."})
        argument_list.append({
            "opts": ("-A", "--aligner"),
            "action": Radio,
            "type": str.lower,
            "choices": PluginLoader.get_available_extractors("align"),
            "default": default_aligner,
            "group": "Plugins",
            "help": "R|Aligner to use."
                    "\nL|cv2-dnn: A cpu only CNN based landmark detector. Faster, less "
                    "resource intensive, but less accurate. Only use this if not using a gpu "
                    " and time is important."
                    "\nL|fan: Face Alignment Network. Best aligner. GPU "
                    "heavy, slow when not running on GPU"})
 </s> add         argument_list.append({"opts": ("-D", "--detector"),
                              "action": Radio,
                              "type": str.lower,
                              "choices":  PluginLoader.get_available_extractors("detect"),
                              "default": default_detector,
                              "group": "Plugins",
                              "help": "R|Detector to use. Some of these have configurable "
                                      "settings in '/config/extract.ini' or 'Settings > Configure "
                                      "Extract 'Plugins':"
                                      "\nL|cv2-dnn: A CPU only extractor which is the least "
                                      "reliable and least resource intensive. Use this if not "
                                      "using a GPU and time is important."
                                      "\nL|mtcnn: Good detector. Fast on CPU, faster on GPU. Uses "
                                      "fewer resources than other GPU detectors but can often "
                                      "return more false positives."
                                      "\nL|s3fd: Best detector. Fast on GPU, slow on CPU. Can "
                                      "detect more faces and fewer false positives than other "
                                      "GPU detectors, but is a lot more resource intensive."})
        argument_list.append({"opts": ("-A", "--aligner"),
                              "action": Radio,
                              "type": str.lower,
                              "choices": PluginLoader.get_available_extractors("align"),
                              "default": default_aligner,
                              "group": "Plugins",
                              "help": "R|Aligner to use."
                                      "\nL|cv2-dnn: A CPU only landmark detector. Faster, less "
                                      "resource intensive, but less accurate. Only use this if "
                                      "not using a GPU and time is important."
                                      "\nL|fan: Best aligner. Fast on GPU, slow on CPU."})
        argument_list.append({"opts": ("-M", "--masker"),
                              "action": Radio,
                              "type": str.lower,
                              "choices": PluginLoader.get_available_extractors("mask"),
                              "default": "components",
                              "group": "Plugins",
                              "help": "R|Masker to use."
                                      "\nL|none: An array of all ones is created to provide a 4th "
                                      "channel that will not mask any portion of the image."
                                      "\nL|components: Mask designed to provide facial "
                                      "segmentation based on the positioning of landmark "
                                      "locations. A convenx hull is constructed around the "
                                      "exterior of the landmarks to create a mask."
                                      "\nL|extended: Mask designed to provide facial segmentation "
                                      "based on the positioning of landmark locations. A convenx "
                                      "hull is constructed around the exterior of the landmarks "
                                      "and the mask is extended upwards onto the forehead."
                                      "\nL|vgg-clear: Mask designed to provide smart segmentation "
                                      "of mostly frontal faces clear of obstructions.  Profile "
                                      "faces and obstructions may result in sub-par performance."
                                      "\nL|vgg-obstructed: Mask designed to provide smart "
                                      "segmentation of mostly frontal faces. The mask model has "
                                      "been specifically trained to recognize some facial "
                                      "obstructions (hands and eyeglasses). Profile faces may "
                                      "result in sub-par performance."
                                      "\nL|unet-dfl: Mask designed to provide smart segmentation "
                                      "of mostly frontal faces. The mask model has been trained "
                                      "by community members and will need testing for further "
                                      "description. Profile faces may result in sub-par "
                                      "performance."})
            loss = self.model.predictors[self.side].train_on_batch(x=model_inputs, y=model_targets)
          """ Train a batch """
          logger.trace("Training one step: (side: %s)", self.side)
          batch = self.get_next(do_preview)
          try:
            loss = self.model.predictors[self.side].train_on_batch(x=model_inputs, y=model_targets)
          except tf_errors.ResourceExhaustedError as err:
              msg = ("You do not have enough GPU memory available to train the selected model at "
                     "the selected settings. You can try a number of things:"
                     "\n1) Close any other application that is using your GPU (web browsers are "
                     "particularly bad for this)."
keep keep keep keep replace keep keep keep keep keep
 Smart Mask Exposure for Extraction & Training (#831)

Smart Masks - Initial Commit 
plugins/train/trainer/_base.py