          frame_size = (predicted["image"].shape[1], predicted["image"].shape[0])
          new_image = self.get_new_image(predicted, frame_size)
          patched_face = self.post_warp_adjustments(predicted, new_image)
          patched_face = self.scale_image(patched_face)
          patched_face = np.rint(patched_face * 255.0).astype("uint8")
          if self.writer_pre_encode is not None:
              patched_face = self.writer_pre_encode(patched_face)
          logger.trace("Patched image: '%s'", predicted["filename"])
          return patched_face
  
 
</s> remove         new_image = self.get_new_image(predicted, frame_size)
        patched_face = self.post_warp_adjustments(predicted, new_image)
 </s> add         new_image, background = self.get_new_image(predicted, frame_size)
        patched_face = self.post_warp_adjustments(background, new_image) </s> remove     def post_warp_adjustments(self, predicted, new_image):
 </s> add     def post_warp_adjustments(self, background, new_image): </s> remove             logger.trace("Patch queue got: '%s'", item["filename"])

            try:
                image = self.patch_image(item)
            except Exception as err:  # pylint: disable=broad-except
                # Log error and output original frame
                logger.error("Failed to convert image: '%s'. Reason: %s",
                             item["filename"], str(err))
                image = item["image"]
                # UNCOMMENT THIS CODE BLOCK TO PRINT TRACEBACK ERRORS
                # import sys
                # import traceback
                # exc_info = sys.exc_info()
                # traceback.print_exception(*exc_info)

            logger.trace("Out queue put: %s", item["filename"])
            out_queue.put((item["filename"], image))
 </s> add             for item in items:
                logger.trace("Patch queue got: '%s'", item["filename"])
                try:
                    image = self.patch_image(item)
                except Exception as err:  # pylint: disable=broad-except
                    # Log error and output original frame
                    logger.error("Failed to convert image: '%s'. Reason: %s",
                                 item["filename"], str(err))
                    image = item["image"]
                    # UNCOMMENT THIS CODE BLOCK TO PRINT TRACEBACK ERRORS
                    # import sys
                    # import traceback
                    # exc_info = sys.exc_info()
                    # traceback.print_exception(*exc_info)

                logger.trace("Out queue put: %s", item["filename"])
                out_queue.put((item["filename"], image)) </s> remove             mask = np.repeat(new_image[:, :, -1][:, :, np.newaxis], 3, axis=-1)
            foreground = new_image[:, :, :3]
            background = (predicted["image"][:, :, :3] / 255.0) * (1.0 - mask)

 </s> add             foreground, mask = np.split(new_image, (3, ), axis=-1) </s> remove             frame = foreground + background

 </s> add             background *= (1.0 - mask)
            background += foreground
            frame = background
        patched_face *= 255.0
        patched_face = np.rint(
            patched_face,
            out=np.empty(patched_face.shape, dtype="uint8"),
            casting='unsafe'
        )
          frame_size = (predicted["image"].shape[1], predicted["image"].shape[0])
          new_image = self.get_new_image(predicted, frame_size)
          patched_face = self.post_warp_adjustments(predicted, new_image)
          patched_face = self.scale_image(patched_face)
        patched_face *= 255.0
        patched_face = np.rint(
            patched_face,
            out=np.empty(patched_face.shape, dtype="uint8"),
            casting='unsafe'
        )
          if self.writer_pre_encode is not None:
              patched_face = self.writer_pre_encode(patched_face)
          logger.trace("Patched image: '%s'", predicted["filename"])
          return patched_face
  
keep keep keep keep replace keep keep keep keep keep
 Optimized numpy functions in Converter (#838) 
lib/convert.py