apple / apple/coremltools

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

Open
#2,392 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
5.4k
Forks
850
Avg merge
4d 5h
Merged PRs (30d)
10

Description

## ❓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

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the NeuralNetworkBuilder usage and the if-layer construction described in the issue, then inspect how the three separate .mlmodel files are represented. Determine whether existing model-composition support can place complete branch models into the conditional flow without rewriting their layers; done means documenting a supported approach or limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.