|
34 | 34 | output_dir = str(args.output_dir) |
35 | 35 |
|
36 | 36 | if os.path.exists(output_dir): |
37 | | - shutil.rmtree(output_dir) |
| 37 | + raise Exception(f"Output directory {output_dir} already exists. Please make delete it before running script.") |
38 | 38 | os.makedirs(output_dir) |
39 | 39 |
|
| 40 | + coreml_extract_path = os.path.join(os.getcwd(), "extracted_coreml_models") |
| 41 | + if os.path.exists(coreml_extract_path): |
| 42 | + raise Exception(f"{coreml_extract_path} already exists. Please delete it before running script.") |
| 43 | + |
40 | 44 | extract_script_path = os.path.join(os.path.dirname(__file__), "../scripts/extract_coreml_models.py") |
41 | 45 | extracted_path = "extracted_coreml_models/model_1/lowered_module/model.mlpackage" |
42 | 46 |
|
43 | 47 | subprocess.run(["python", extract_script_path, "--model", model1_path]) |
44 | 48 | items = os.listdir("extracted_coreml_models") |
45 | 49 | assert len(items) == 1, "Expected one CoreML partition" |
46 | 50 | shutil.copytree(extracted_path, f"{output_dir}/model1.mlpackage") |
47 | | - shutil.rmtree("extracted_coreml_models") |
48 | 51 |
|
49 | 52 | subprocess.run(["python", extract_script_path, "--model", model2_path]) |
50 | 53 | items = os.listdir("extracted_coreml_models") |
51 | 54 | assert len(items) == 1, "Expected one CoreML partition" |
52 | 55 | shutil.copytree(extracted_path, f"{output_dir}/model2.mlpackage") |
53 | | - shutil.rmtree("extracted_coreml_models") |
54 | | - |
55 | 56 |
|
56 | 57 | desc = ct.utils.MultiFunctionDescriptor() |
57 | 58 |
|
|
0 commit comments