          crop = slice(48, 208)
          face = image[crop, crop]
          old_face = face.copy()
  
          face = cv2.resize(face, (size, size))
          face = numpy.expand_dims(face, 0)
          new_face = self.encoder(face / 255.0)[0]
          new_face = numpy.clip(new_face * 255, 0, 255).astype(image.dtype)
          new_face = cv2.resize(new_face, (160, 160))
  
          if self.use_avg_color_adjust:
              self.adjust_avg_color(old_face,new_face)
          if self.use_smooth_mask:
              self.smooth_mask(old_face,new_face)
 
</s> remove     def patch_image( self, original, face_detected, size ):
        #assert image.shape == (256, 256, 3)
        image = cv2.resize(face_detected.image, (256, 256))
        crop = slice(48, 208)
        face = image[crop, crop]
        old_face = face.copy()
 </s> add     def patch_image(self, frame, detected_face, size):
        """ Patch swapped face onto original image """
        # pylint: disable=no-member
        # assert image.shape == (256, 256, 3)
        padding = 48
        face_size = 256
        detected_face.load_aligned(frame, face_size, padding,
                                   align_eyes=False)
        src_face = detected_face.aligned_face

        crop = slice(padding, face_size - padding)
        process_face = src_face[crop, crop]
        old_face = process_face.copy() </s> remove             self.adjust_avg_color(old_face,new_face)
 </s> add             self.adjust_avg_color(old_face, new_face) </s> remove             self.smooth_mask(old_face,new_face)
 </s> add             self.smooth_mask(old_face, new_face)

        new_face = self.superpose(src_face, new_face, crop)
        new_image = frame.copy() </s> remove     def smooth_mask(self,img_old,img_new):
        w,h,c = img_new.shape
        crop = slice(0,w)
        mask = numpy.zeros_like(img_new)
        mask[h//15:-h//15,w//15:-w//15,:] = 255
        mask = cv2.GaussianBlur(mask,(15,15),10)
        img_new[crop,crop] = mask/255*img_new + (1-mask/255)*img_old
 </s> add     @staticmethod
    def smooth_mask(old_face, new_face):
        """ Smooth the mask """
        width, height, _ = new_face.shape
        crop = slice(0, width)
        mask = np.zeros_like(new_face)
        mask[height // 15:-height // 15, width // 15:-width // 15, :] = 255
        mask = cv2.GaussianBlur(mask,  # pylint: disable=no-member
                                (15, 15),
                                10)
        new_face[crop, crop] = (mask / 255 * new_face +
                                (1 - mask / 255) * old_face) </s> remove         new_face = self.superpose(image, new_face, crop)
        original[slice(face_detected.y, face_detected.y + face_detected.h), slice(face_detected.x, face_detected.x + face_detected.w)] = cv2.resize(new_face, (face_detected.w, face_detected.h))
        return original
 </s> add         cv2.warpAffine(
            new_face,
            detected_face.adjusted_matrix,
            (detected_face.frame_dims[1], detected_face.frame_dims[0]),
            new_image,
            flags=cv2.WARP_INVERSE_MAP | cv2.INTER_CUBIC,
            borderMode=cv2.BORDER_TRANSPARENT)
        return new_image
        process_face = cv2.resize(process_face,
                                  (size, size),
                                  interpolation=cv2.INTER_AREA)
        process_face = np.expand_dims(process_face, 0)

        new_face = self.encoder(process_face / 255.0)[0]
        new_face = np.clip(new_face * 255, 0, 255).astype(src_face.dtype)
        new_face = cv2.resize(
            new_face,
            (face_size - padding * 2, face_size - padding * 2),
            interpolation=cv2.INTER_CUBIC)
          crop = slice(48, 208)
          face = image[crop, crop]
          old_face = face.copy()
  
        process_face = cv2.resize(process_face,
                                  (size, size),
                                  interpolation=cv2.INTER_AREA)
        process_face = np.expand_dims(process_face, 0)

        new_face = self.encoder(process_face / 255.0)[0]
        new_face = np.clip(new_face * 255, 0, 255).astype(src_face.dtype)
        new_face = cv2.resize(
            new_face,
            (face_size - padding * 2, face_size - padding * 2),
            interpolation=cv2.INTER_CUBIC)
        process_face = cv2.resize(process_face,
                                  (size, size),
                                  interpolation=cv2.INTER_AREA)
        process_face = np.expand_dims(process_face, 0)

        new_face = self.encoder(process_face / 255.0)[0]
        new_face = np.clip(new_face * 255, 0, 255).astype(src_face.dtype)
        new_face = cv2.resize(
            new_face,
            (face_size - padding * 2, face_size - padding * 2),
            interpolation=cv2.INTER_CUBIC)
        process_face = cv2.resize(process_face,
                                  (size, size),
                                  interpolation=cv2.INTER_AREA)
        process_face = np.expand_dims(process_face, 0)

        new_face = self.encoder(process_face / 255.0)[0]
        new_face = np.clip(new_face * 255, 0, 255).astype(src_face.dtype)
        new_face = cv2.resize(
            new_face,
            (face_size - padding * 2, face_size - padding * 2),
            interpolation=cv2.INTER_CUBIC)
        process_face = cv2.resize(process_face,
                                  (size, size),
                                  interpolation=cv2.INTER_AREA)
        process_face = np.expand_dims(process_face, 0)

        new_face = self.encoder(process_face / 255.0)[0]
        new_face = np.clip(new_face * 255, 0, 255).astype(src_face.dtype)
        new_face = cv2.resize(
            new_face,
            (face_size - padding * 2, face_size - padding * 2),
            interpolation=cv2.INTER_CUBIC)
        process_face = cv2.resize(process_face,
                                  (size, size),
                                  interpolation=cv2.INTER_AREA)
        process_face = np.expand_dims(process_face, 0)

        new_face = self.encoder(process_face / 255.0)[0]
        new_face = np.clip(new_face * 255, 0, 255).astype(src_face.dtype)
        new_face = cv2.resize(
            new_face,
            (face_size - padding * 2, face_size - padding * 2),
            interpolation=cv2.INTER_CUBIC)
  
          if self.use_avg_color_adjust:
              self.adjust_avg_color(old_face,new_face)
          if self.use_smooth_mask:
              self.smooth_mask(old_face,new_face)
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
 Fix convert-adjust (#531)

* Add dimensions to alignments + refactor

* Add frame_dims + funcs to DetectFaces. Add alignments lib

* Convert Adjust working

* Refactor and tidy up 
plugins/convert/Convert_Adjust.py