coremltools icon indicating copy to clipboard operation
coremltools copied to clipboard

How to make combined mlmodel based on seperate mlmodels? adding if-else control flow

Open xueyingxin opened this issue 1 year ago • 1 comments

❓Question

I want to use coremltools to help accomplish combining some separate coreml models to form a bigger one. For example, I have models: main.mlmodel, if_branch.mlmodel, else_branch.mlmodel, each have so many layers. I want to make another mlmodel based on those three. And the flow should be like this: Inputs include input to "main" and a condition input "cond". Input feed to "main", then output of it will go to either "if_branch" or "else_branch" based on the other input "cond".

I tried using "NeuralNetworkBuilder" to construct the bigger model. But when constructing the if layer, what kind of method(api) should I use to move all layers in "if_branch.mlmodel" to the "ifbranch" of the if layer instead of rewriting each layer into "ifbranch"? image

xueyingxin avatar Nov 12 '24 06:11 xueyingxin

It sounds like you should be using more than one model. It sounds like you want to create a model pipeline.

Model pipelines allow you to create an MLModel that consists of other MLModels. Models in the pipeline can take as input earlier Model's output.

Model Pipeline Resources

TobyRoseman avatar Nov 12 '24 22:11 TobyRoseman