invoke-ai/InvokeAI · error · TypeError
Expected LlavaOnevisionProcessor, got {type(processor).__nam
Error message
Expected LlavaOnevisionProcessor, got {type(processor).__name__} What it means
After the model passes its type check, AutoProcessor.from_pretrained is called on the model path and the result is asserted to be a LlavaOnevisionProcessor. AutoProcessor returns whatever class the checkpoint's processor_config/preprocessor_config declares; if the checkpoint ships a generic CLIP/OPT processor or an incompatible config, the isinstance check fails and this TypeError is raised before any inference runs.
Source
Thrown at invokeai/app/api/routers/utilities.py:271
if task_id is not None:
events.emit_llm_task_progress(task_id=task_id, user_id=user_id, phase="loading_model", message="Loading model")
with _model_load_lock:
loaded_model = model_manager.load.load_model(model_config, user_id=user_id)
# Load the image from InvokeAI's image store
image = ApiDependencies.invoker.services.images.get_pil_image(image_name)
image = image.convert("RGB")
with torch.no_grad(), loaded_model.model_on_device() as (_, model):
if not isinstance(model, LlavaOnevisionForConditionalGeneration):
raise TypeError(f"Expected LlavaOnevisionForConditionalGeneration, got {type(model).__name__}")
model_abs_path = _resolve_model_path(model_config.path)
processor = AutoProcessor.from_pretrained(model_abs_path, local_files_only=True)
if not isinstance(processor, LlavaOnevisionProcessor):
raise TypeError(f"Expected LlavaOnevisionProcessor, got {type(processor).__name__}")
pipeline = LlavaOnevisionPipeline(model, processor)
model_device = next(model.parameters()).device
progress_callback = _make_progress_callback(events, task_id, user_id)
output = pipeline.run(
prompt=instruction,
images=[image],
device=model_device,
dtype=TorchDevice.choose_torch_dtype(),
progress_callback=progress_callback,
)
return output
@utilities_router.post(View on GitHub (pinned to 0b6a024f2f)
Solutions
- Re-download or re-save the model so its directory contains a valid LlavaOnevision processor config (AutoProcessor.save_pretrained from a correct transformers version)
- Verify the files at _resolve_model_path(model_config.path) — check preprocessor_config.json / processor_config.json exist and declare llava_onevision
- Confirm the installed transformers version matches the version used to create the checkpoint
- Clear the partially-downloaded model cache entry and re-fetch
Example fix
# before
processor = AutoProcessor.from_pretrained(model_abs_path, local_files_only=True)
pipeline = LlavaOnevisionPipeline(model, processor)
# after
processor = AutoProcessor.from_pretrained(model_abs_path, local_files_only=True)
if not isinstance(processor, LlavaOnevisionProcessor):
raise TypeError(f"Expected LlavaOnevisionProcessor, got {type(processor).__name__}")
pipeline = LlavaOnevisionPipeline(model, processor) Defensive patterns
Strategy: type-guard
Validate before calling
from transformers import AutoProcessor
p = AutoProcessor.from_pretrained(model_path, local_files_only=True)
assert p.__class__.__name__ == "LlavaOnevisionProcessor", f"got {p.__class__.__name__}" Type guard
def is_llava_onevision_processor(processor) -> bool:
from transformers import LlavaOnevisionProcessor
return isinstance(processor, LlavaOnevisionProcessor) Try / catch
try:
resp = requests.post(f"{base}/utilities/image_to_prompt", json={...})
resp.raise_for_status()
except requests.HTTPError as e:
if "Expected LlavaOnevisionProcessor" in e.response.text:
re_download_model(model_key) Prevention
- Verify checkpoint directory contains preprocessor_config.json before use
- Re-save processors with the same transformers version used at inference
- Avoid mixing processors from llava-1.5 conversions into onevision checkpoints
When it happens
Trigger: POST /utilities/image_to_prompt where the LLaVA checkpoint directory lacks a LLaVA OneVision preprocessor_config.json or contains a processor saved by an older/incompatible transformers release, so AutoProcessor instantiates e.g. CLIPImageProcessor+LlamaTokenizer instead of LlavaOnevisionProcessor.
Common situations: Incomplete downloads (missing processor config files), checkpoints converted from llava-1.5 checkpoints without re-saving the processor, local_files_only=True hiding a partially-populated directory, mismatched transformers version saving/loading different processor classes.
Related errors
- Expected LlavaOnevisionForConditionalGeneration, got {type(m
- Unexpected error while resuming queue: {e}
- Unexpected error while pausing queue: {e}
- Expected PreTrainedModel for text encoder, got {type(text_en
- Expected PreTrainedTokenizerBase for tokenizer, got {type(to
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/b91c086e8506b3c4.
Report an issue: GitHub.