          offset = (backgrounds.shape[1] - foregrounds.shape[1]) // 2
          new_images = list()
          for idx, img in enumerate(backgrounds):
              img[offset:offset + foregrounds[idx].shape[0],
                  offset:offset + foregrounds[idx].shape[1]] = foregrounds[idx]
              new_images.append(img)
          retval = np.array(new_images)
          logger.debug("Overlayed foreground. Shape: %s", retval.shape)
          return retval
  
 
</s> remove             images = np.array([cv2.addWeighted(img, 1.0,  # pylint: disable=no-member
                                               masks3[idx], 0.3,
                                               0)
 </s> add             images = np.array([cv2.addWeighted(img,  # pylint: disable=no-member
                                               1.0, masks3[idx], 0.3, 0) </s> remove             for plugin in (self._aligner, self._detector):
 </s> add             for plugin in (self._detector, self._aligner, self._masker): </s> remove             # Hacky split across 2 plugins
            available_vram = (vram_free - vram_required) // 2
            for plugin in (self._aligner, self._detector):
 </s> add             # Hacky split across 3 plugins
            available_vram = (vram_free - vram_required) // 3
            for plugin in (self._detector, self._aligner, self._masker): </s> remove             image = cv2.copyMakeBorder(  # pylint:disable=no-member
                image,
                pad_t,
                pad_b,
                pad_l,
                pad_r,
                cv2.BORDER_CONSTANT)  # pylint:disable=no-member
 </s> add             image = cv2.copyMakeBorder(image,  # pylint:disable=no-member
                                       pad_t,
                                       pad_b,
                                       pad_l,
                                       pad_r,
                                       cv2.BORDER_CONSTANT)  # pylint:disable=no-member </s> remove             logger.trace("Batch has no mask")
            retval = dict(targets=batch)
 </s> add             masks = [np.ones((size_list_of_batches[-1].shape[:-1] + (1,)), dtype='float32')]
        retval = dict(targets=targets, masks=masks)
                offset:offset + foregrounds[idx].shape[1], :3] = foregrounds[idx]
          offset = (backgrounds.shape[1] - foregrounds.shape[1]) // 2
          new_images = list()
          for idx, img in enumerate(backgrounds):
              img[offset:offset + foregrounds[idx].shape[0],
                offset:offset + foregrounds[idx].shape[1], :3] = foregrounds[idx]
              new_images.append(img)
          retval = np.array(new_images)
          logger.debug("Overlayed foreground. Shape: %s", retval.shape)
          return retval
  
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