          with open(filename, "wb") as out_file:
              out_file.write(img)
          return f_hash
  
      def align_eyes(self, face, image):
          """ Re-extract a face with the pupils forced to be absolutely horizontally aligned """
          umeyama_landmarks = face.aligned_landmarks
          leftEyeCenter = umeyama_landmarks[42:48].mean(axis=0)
          rightEyeCenter = umeyama_landmarks[36:42].mean(axis=0)
          eyesCenter = umeyama_landmarks[36:48].mean(axis=0)
 
</s> remove         leftEyeCenter = umeyama_landmarks[42:48].mean(axis=0)
        rightEyeCenter = umeyama_landmarks[36:42].mean(axis=0)
        eyesCenter = umeyama_landmarks[36:48].mean(axis=0)
        dY = rightEyeCenter[1] - leftEyeCenter[1]
        dX = rightEyeCenter[0] - leftEyeCenter[0]
        theta = np.pi - np.arctan2(dY, dX)
 </s> add         left_eye_center = umeyama_landmarks[42:48].mean(axis=0)
        right_eye_center = umeyama_landmarks[36:42].mean(axis=0)
        d_y = right_eye_center[1] - left_eye_center[1]
        d_x = right_eye_center[0] - left_eye_center[0]
        theta = np.pi - np.arctan2(d_y, d_x) </s> remove         with open(statefile, "rb") as inp:
            state = self.serializer.unmarshal(inp.read().decode("utf-8"))
            trainer = state.get("name", None)
 </s> add         state = self.serializer.load(statefile)
        trainer = state.get("name", None) </s> remove             with open(filename, "r") as cfgfile:
                cfg = self.serializer.unmarshal(cfgfile.read())
 </s> add             cfg = self.serializer.load(filename) </s> remove                                   "{}_state.{}".format(self.model_name, serializer.ext))
        with open(state_file, "rb") as inp:
            state = serializer.unmarshal(inp.read().decode("utf-8"))
            session_names = ["session_{}".format(key)
                             for key in state["sessions"].keys()]
 </s> add                                   "{}_state.{}".format(self.model_name, serializer.file_extension))
        state = serializer.load(state_file)
        session_names = ["session_{}".format(key)
                         for key in state["sessions"].keys()] </s> remove         try:
            with open(self.filename, "wb") as out:
                state = {"name": self.name,
                         "sessions": self.sessions,
                         "lowest_avg_loss": self.lowest_avg_loss,
                         "iterations": self.iterations,
                         "inputs": self.inputs,
                         "training_size": self.training_size,
                         "config": _CONFIG}
                state_json = self.serializer.marshal(state)
                out.write(state_json.encode("utf-8"))
        except IOError as err:
            logger.error("Unable to save model state: %s", str(err.strerror))
 </s> add         state = {"name": self.name,
                 "sessions": self.sessions,
                 "lowest_avg_loss": self.lowest_avg_loss,
                 "iterations": self.iterations,
                 "inputs": self.inputs,
                 "training_size": self.training_size,
                 "config": _CONFIG}
        self.serializer.save(self.filename, state)
    @staticmethod
    def align_eyes(face, image):
          with open(filename, "wb") as out_file:
              out_file.write(img)
          return f_hash
  
    @staticmethod
    def align_eyes(face, image):
          """ Re-extract a face with the pupils forced to be absolutely horizontally aligned """
          umeyama_landmarks = face.aligned_landmarks
          leftEyeCenter = umeyama_landmarks[42:48].mean(axis=0)
          rightEyeCenter = umeyama_landmarks[36:42].mean(axis=0)
          eyesCenter = umeyama_landmarks[36:48].mean(axis=0)
keep keep keep keep replace keep keep keep keep keep
 Standardize serialization (#903)

* Standardize serialization

- Linting
- Standardize serializer use throughout code
- Extend serializer to load and save files
- Always load and save in utf-8
- Create documentation 
tools/lib_alignments/media.py