Ideogram v2 is an outstanding new inpainting model

Posted October 22, 2024 by

Today Ideogram are launching their new inpainting feature for Ideogram v2. We're thrilled to be partnering with Ideogram, to bring Ideogram v2 to Replicate's 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 updated our open-source inpainter.app demo to use Ideogram v2.

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.

Check out these example projects:

  • Inpainter - Open-source Next.js app for inpainting images.
  • Outpainter - Open-source Nuxt.js app for extending images beyond their original canvas.

Let us know what you build on X or Discord.