Ideogram v2 is an outstanding new inpainting model

Today Ideogram are launching their new inpainting feature for Ideogram v2. We’re thrilled to be partnering with Ideogram, to bring Ideogram v2 to the Replicate API. We’ve been blown away by the quality of this model, it’s really good.

Ideogram v2 comes in two flavors:

For example, here is a herd of dinosaurs grazing on the Bucolic Green Hills:

Ideogram v2 is not just for inpainting, you can use it to generate any type of image. In our tests, we found it to be particularly good at generating text.

Run Ideogram v2 with an API on Replicate

To inpaint an image with the Replicate Python client, run

import replicate
from pathlib import Path

output = replicate.run(
    "ideogram-ai/ideogram-v2",
    input={
        "prompt": "Dinosaurs grazing on a hill",
        "image": Path("desktop.png"),
        "mask": Path("desktop-mask.png")
    }
)
print(output.url)

Or in JavaScript:

import Replicate from "replicate";
import fs from "node:fs";
import path from "node:path";

const replicate = new Replicate({
  auth: process.env.REPLICATE_API_TOKEN,
});

const image = fs.readFileSync(path.resolve(__dirname, "desktop.png"));
const mask = fs.readFileSync(path.resolve(__dirname, "desktop-mask.png"));

const output = await replicate.run("ideogram-ai/ideogram-v2", {
  input: {
    prompt: "Dinosaurs grazing on a hill",
    image,
    mask,
  },
});

console.log(output.url());

Live demo

We put together a little web widget where you can try the inpainter live in the browser. Type a prompt to get started, and draw with your mouse to mask out parts of the image. Then enter a new prompt and hit submit.

Getting the best inpainting results

Here are some tips and tricks. Your mileage might vary!

  • As a rule of thumb, when Magic Prompt is off you should try to describe the whole scene and not just the inpainted region.
  • When Magic Prompt is on, the model will try to rewrite your prompt based on both the original prompt and the image, so you don’t necessarily need to describe the whole image.
  • If you only describe the inpainting region, the model will put more emphasis on the prompt which could produce better results.

Next steps

Inpainting has lots of fun applications. You can duplicate fonts, place objects in rooms, generate sprite maps for games, and lots more. Let us know what you build on X or Discord!