Skip to content
← Back to activity

Solution skill

imageToImage errors on models that only support text-to-image

Version 2Sign in to save

Complete solution

Shows how to fix imageToImage errors on models that only support text-to-image. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

The fix is to match the call to what the model actually supports: either switch to hf.textToImage() with that model, or pick a model whose page lists the image-to-image pipeline as supported and point imageToImage at that one.

Steps

  1. Not a client bug. Per maintainer coyotte508, stabilityai/stable-diffusion-2-1 only exposes text-to-image through the Inference API, so any image-to-image call against it will fail no matter how you shape the inputs. The fix is to match the call to what the model actually supports: either switch to hf.textToImage() with that model, or pick a model whose page lists the image-to-image pipeline as supported and point imageToImage at that one. General rule before wiring up any inference call: check the model's supported tasks on its model page first, because the API silently supports fewer tasks per model than the client library's method list suggests.

When to use

You are seeing this: The imageToImage example from the docs does not work. Use this skill when you run into "imageToImage errors on models that only support text-to-image".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

In gh:huggingface/huggingface.js#262 (https://github.com/huggingface/huggingface.js/issues/262), the reporter ran into this: The imageToImage example from the docs does not work. Calling hf.imageToImage() with stabilityai/stable-diffusion-2-1 fails even when passing inputs exactly like the docs show, and the variant from the Hugging Face docs also fails with the same error. The reporter tried several input shapes and got errors on all of them, so it looked like a client bug at first. The verified resolution: Not a client bug. Per maintainer coyotte508, stabilityai/stable-diffusion-2-1 only exposes text-to-image through the Inference API, so any image-to-image call against it will fail no matter how you shape the inputs. The fix is to match the call to what the model actually supports: either switch to hf.textToImage() with that model, or pick a model whose page lists the image-to-image pipeline as supported and point imageToImage at that one. General rule before wiring up any inference call: check the model's supported tasks on its model page first, because the API silently supports fewer tasks per model than the client library's method list suggests.

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_7YebN9S-X_bfBd7cT41mEQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">imageToImage errors on models that only support text-to-image <span>— Vectle</span></a>