invoke-ai/InvokeAI · error · RuntimeError

Unknown model (%s)

Error message

Unknown model (%s)

What it means

geffnet's create_model dispatches by looking the model name up in the factory module's globals(): if model_name is not a registered factory function name, it raises RuntimeError('Unknown model (%s)'). The factory only knows names for which a per-model builder function (e.g. efficientnet_b0, mobilenetv3_large_100) exists in geffnet.model_factory.

Source

Thrown at invokeai/backend/image_util/normal_bae/nets/submodules/efficientnet_repo/geffnet/model_factory.py:22

from .gen_efficientnet import *
from .mobilenetv3 import *


def create_model(
        model_name='mnasnet_100',
        pretrained=None,
        num_classes=1000,
        in_chans=3,
        checkpoint_path='',
        **kwargs):

    model_kwargs = dict(num_classes=num_classes, in_chans=in_chans, pretrained=pretrained, **kwargs)

    if model_name in globals():
        create_fn = globals()[model_name]
        model = create_fn(**model_kwargs)
    else:
        raise RuntimeError('Unknown model (%s)' % model_name)

    if checkpoint_path and not pretrained:
        load_checkpoint(model, checkpoint_path)

    return model

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Check the exact registered names (e.g. [n for n in dir(geffnet.model_factory) if not n.startswith('_')]) and pass one verbatim, such as 'efficientnet_b0'.
  2. Correct dashes/dots to underscores: 'efficientnet-b0' -> 'efficientnet_b0'.
  3. If the name comes from timm or another library, use that library's create_model, or map it to the equivalent geffnet name.
  4. If a genuinely new architecture is needed, add a builder function to geffnet.model_factory so the name exists in globals().

Example fix

// before
model = geffnet.create_model('tf_efficientnet_b0')  # RuntimeError: Unknown model
// after
model = geffnet.create_model('efficientnet_b0')  # registered factory name
Defensive patterns

Strategy: validation

Validate before calling

import geffnet.model_factory as mf
valid = {n for n in dir(mf) if callable(getattr(mf, n)) and not n.startswith('_')}
if model_name not in valid:
    raise ValueError(f'{model_name!r} not in geffnet factory; pick from sorted(valid)')

Type guard

def is_known_geffnet_model(name: str) -> bool:
    import geffnet.model_factory as mf
    return callable(getattr(mf, name, None))

Try / catch

try:
    model = geffnet.create_model(model_name)
except RuntimeError as e:
    if 'Unknown model' in str(e):
        raise ValueError(f'{model_name} is not a registered geffnet model') from e
    raise

Prevention

When it happens

Trigger: create_model(model_name='...') where model_name does not match any builder function defined in geffnet/model_factory.py — e.g. any name not in the module's globals(), including timm-style names, suffixed names, or typos.

Common situations: Using timm model identifiers in geffnet (different naming scheme); typos like 'efficientnet-b0' (dash) instead of 'efficientnet_b0'; asking for a model variant the installed geffnet version predates; assuming create_model resolves paths like 'geffnet/efficientnet_b0'.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/e8130925bd3ae0f8. Report an issue: GitHub.