You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When working withlarge Core ML models, for instance a big [Stable Diffusion](https://github.com/apple/ml-stable-diffusion) model, the process might be killed due to memory issues. You can solve the issue by chunking the previously exported model into two pieces, and combine them into a Core ML pipeline model.
178
+
In certain scenarios, you may want to break a large Core MLmodel into two smaller models. For instance, if you are deploying a model to run on neural engine on an iPhone, it cannot be larger than 1GB. If you are working with, say, [Stable Diffusion](https://github.com/apple/ml-stable-diffusion) 1.5model which is1.72GB large (Float 16 precision), then it needs to be broken up into two chunks, each less than 1GB. The utility `ct.models.utils.bisect_model` will allow you to do exactly that. When using this API, you can also opt-in to package the two chunks of the model into a pipeline model, so that its still a single mlpackage file, with the two models arranged in a sequential manner.
179
179
180
-
The example below shows how to bisect a model, test the accuracy, andsavethem on disk.
180
+
The example below shows how to bisect a model, test the accuracy, andsave them on disk.
181
181
182
182
```python
183
+
183
184
import coremltools as ct
184
185
185
186
model_path="my_model.mlpackage"
186
187
output_dir="./output/"
187
188
188
189
# The following code will produce two chunks models:
189
190
# `./output/my_model_chunk1.mlpackage` and `./output/my_model_chunk2.mlpackage`
191
+
# It also compares the output numerical of the original Core ML model with the chunked models.
0 commit comments