  
  landmarks_2D = numpy.stack( [ mean_face_x, mean_face_y ], axis=1 )
  
  def get_align_mat(face):
      return umeyama( numpy.array(face.landmarks[17:]), landmarks_2D, True )[0:2]
 
</s> remove         new_face = self.autoencoder.predict( face / 255.0 )[0]
 </s> add         new_face = self.encoder( face / 255.0 )[0]
 </s> remove     def save_model_weights(self):
        encoder.save_weights(self.arguments.model_dir + '/encoder.h5')
        decoder_A.save_weights(self.arguments.model_dir + '/decoder_A.h5')
        decoder_B.save_weights(self.arguments.model_dir + '/decoder_B.h5')
        print('save model weights')

    def show_sample(self, test_A, test_B):
        figure_A = numpy.stack([
            test_A,
            autoencoder_A.predict(test_A),
            autoencoder_B.predict(test_A),
        ], axis=1)
        figure_B = numpy.stack([
            test_B,
            autoencoder_B.predict(test_B),
            autoencoder_A.predict(test_B),
        ], axis=1)

        figure = numpy.concatenate([figure_A, figure_B], axis=0)
        figure = figure.reshape((4, 7) + figure.shape[1:])
        figure = stack_images(figure)

        figure = numpy.clip(figure * 255, 0, 255).astype('uint8')

        if self.arguments.preview is True:
            cv2.imshow('', figure)
        if not self.arguments.preview or self.arguments.write_image:
            cv2.imwrite('_sample.jpg', figure)

 </s> add  </s> remove def load_images(image_paths, convert=None):
    iter_all_images = (cv2.imread(fn) for fn in image_paths)
    if convert:
        iter_all_images = (convert(img) for img in iter_all_images)
    for i, image in enumerate(iter_all_images):
        if i == 0:
            all_images = numpy.empty((len(image_paths), ) + image.shape, dtype=image.dtype)
        all_images[i] = image
    return all_images
 </s> add     def iterator(self):
        while True:
            next_item = self.queue.get()
            if next_item is None:
                break
            yield next_item </s> remove             hull = cv2.convexHull( numpy.array( face_detected.landmarks ).reshape((-1,2)).astype(int) ).flatten().reshape( (-1,2) )
 </s> add             hull = cv2.convexHull( numpy.array( face_detected.landmarksAsXY() ).reshape((-1,2)).astype(int) ).flatten().reshape( (-1,2) )

    return umeyama( numpy.array(face.landmarksAsXY()[17:]), landmarks_2D, True )[0:2]
  
  landmarks_2D = numpy.stack( [ mean_face_x, mean_face_y ], axis=1 )
  
  def get_align_mat(face):
    return umeyama( numpy.array(face.landmarksAsXY()[17:]), landmarks_2D, True )[0:2]
keep keep keep keep replace
 Adding models as plugins + Face filtering (#53) + #39 + #43 + #44 + #49 (#61)

* Making Models as plugins

* Do not reload model on each image #39 + Adding FaceFilter #53

* Adding @lukaville PR for #43 and #44 (possibly)

* Training done in a separate thread

* Better log for plugin load

* Adding a prefetch to train.py #49
(Note that we prefetch 2 batches of images, due to the queue behavior)
+ More compact logging with verbose info included

* correction of DirectoryProcessor signature

* adding missing import

* Convert with parallel preprocessing of files

* Added coverage var for trainer

Added a var with comment. Feel free to add it as argument

* corrections

* Modifying preview and normalization of image + correction

* Cleanup 
lib/aligner.py