                  dir_contents.append(x.path)
  
      return dir_contents
  
  # From: https://stackoverflow.com/questions/22041699/rotate-an-image-without-cropping-in-opencv-in-c
  def rotate_image(image, angle, rotated_width=None, rotated_height=None):
      height, width = image.shape[:2]
      image_center = (width/2, height/2)
      rotation_matrix = cv2.getRotationMatrix2D(image_center, -1.*angle, 1.)
 
</s> remove encoderH5 = 'encoder.h5'
decoder_AH5 = 'decoder_A.h5'
decoder_BH5 = 'decoder_B.h5'
 </s> add hdf = {'encoderH5': 'encoder.h5',
       'decoder_AH5': 'decoder_A.h5',
       'decoder_BH5': 'decoder_B.h5'}
 </s> remove import os, shutil
 </s> add from lib.utils import backup_file </s> remove import os, shutil
 </s> add from lib.utils import backup_file </s> remove         if os.path.isdir(model_dir + "_bk"):
            shutil.rmtree(model_dir + "_bk")
        shutil.move(model_dir,  model_dir + "_bk")
        os.mkdir(model_dir)
 </s> add         for model in hdf.values():
            backup_file(model_dir, model)
 </s> remove         if os.path.isdir(model_dir + "_bk"):
            shutil.rmtree(model_dir + "_bk")
        shutil.move(model_dir,  model_dir + "_bk")
        os.mkdir(model_dir)
        self.encoder.save_weights(str(self.model_dir / encoderH5))
        self.decoder_A.save_weights(str(self.model_dir / decoder_AH5))
        self.decoder_B.save_weights(str(self.model_dir / decoder_BH5))
 </s> add         for model in hdf.values():
            backup_file(model_dir, model)
        self.encoder.save_weights(str(self.model_dir / hdf['encoderH5']))
        self.decoder_A.save_weights(str(self.model_dir / hdf['decoder_AH5']))
        self.decoder_B.save_weights(str(self.model_dir / hdf['decoder_BH5']))
def backup_file(directory, filename):
    """ Backup a given file by appending .bk to the end """
    origfile = join(directory, filename)
    backupfile = origfile + '.bk'
    if exists(backupfile):
        os.remove(backupfile)
    os.rename(origfile, backupfile)

                  dir_contents.append(x.path)
  
      return dir_contents
  
def backup_file(directory, filename):
    """ Backup a given file by appending .bk to the end """
    origfile = join(directory, filename)
    backupfile = origfile + '.bk'
    if exists(backupfile):
        os.remove(backupfile)
    os.rename(origfile, backupfile)

  # From: https://stackoverflow.com/questions/22041699/rotate-an-image-without-cropping-in-opencv-in-c
  def rotate_image(image, angle, rotated_width=None, rotated_height=None):
      height, width = image.shape[:2]
      image_center = (width/2, height/2)
      rotation_matrix = cv2.getRotationMatrix2D(image_center, -1.*angle, 1.)
keep keep keep add keep keep keep keep keep
 Model backup bugfix (#371)

* model backup bugfix - original model

* Model backup bugfix - remaining models 
lib/utils.py