| import sys | |
| from Foundation import NSURL | |
| import CoreML | |
| if len(sys.argv) != 2: | |
| print("usage: CoreMLPyObjCCompileOne.py <path-to-mlpackage-or-mlmodel>") | |
| sys.exit(2) | |
| url = NSURL.fileURLWithPath_(sys.argv[1]) | |
| try: | |
| result = CoreML.MLModel.compileModelAtURL_error_(url, None) | |
| print("COMPILE_RETURN", repr(result)[:800]) | |
| except BaseException as exc: | |
| print("CONTROLLED_EXCEPTION", type(exc).__name__, str(exc)[:800]) | |