Esempio n. 1
0
 def test_save_text(self):
     this = os.path.dirname(__file__)
     onnx_file = os.path.join(this, "models", "coreml_OneHotEncoder_BikeSharing.onnx")
     onnx_model = load_model(onnx_file)
     json_file = os.path.join(this, "models", "coreml_OneHotEncoder_BikeSharing.json")
     json_file_new = os.path.join(this, "models", "coreml_OneHotEncoder_BikeSharing_new.json")
     save_text(onnx_model, json_file_new)
     filecmp.clear_cache()
     content1 = self._parseEOL(json_file)
     content2 = self._parseEOL(json_file_new)
     self.assertTrue(content1 == content2,
                     "Output file from save_text is different than reference output.")
 def get_diff(self, input_file, ref_file):
     this = os.path.dirname(__file__)
     coreml_file = os.path.join(this, "models", input_file)
     cml = coremltools.utils.load_spec(coreml_file)
     onnx_model = convert_coreml(cml)
     output_dir = os.path.join(this, "outmodels")
     output_file = os.path.join(this, "outmodels", ref_file)
     if not os.path.exists(output_dir):
         os.makedirs(output_dir)
     save_text(onnx_model, output_file)
     reference_model = os.path.join(this, "models", ref_file)
     with open(reference_model, 'r') as ref_file:
         with open(output_file, 'r') as output_file:
             diff = set(ref_file).difference(output_file)
     return diff
Esempio n. 3
0
 def test_save_text(self):
     this = os.path.dirname(__file__)
     onnx_file = os.path.join(this, "models",
                              "coreml_OneHotEncoder_BikeSharing.onnx")
     onnx_model = load_model(onnx_file)
     if StrictVersion(onnx.__version__) < StrictVersion('1.4.0'):
         json_file = os.path.join(this, "models",
                                  "coreml_OneHotEncoder_BikeSharing.json")
     else:
         json_file = os.path.join(
             this, "models", "coreml_OneHotEncoder_BikeSharing_Op9.json")
     json_file_new = os.path.join(
         this, "models", "coreml_OneHotEncoder_BikeSharing_new.json")
     save_text(onnx_model, json_file_new)
     try:
         filecmp.clear_cache()
     except AttributeError:
         # Only available in Python 3
         pass
     content1 = self._parseEOL(json_file)
     content2 = self._parseEOL(json_file_new)
     self.assertTrue(
         content1 == content2,
         "Output file from save_text is different than reference output.")