stable-diffusion-v1-5-inpainting
Model ID: @cf/runwayml/stable-diffusion-v1-5-inpainting
Stable Diffusion Inpainting is a latent text-to-image diffusion model capable of generating photo-realistic images given any text input, with the extra capability of inpainting the pictures by using a mask.
More Information Terms & License
Properties
Task Type: Text-to-Image
Code Examples
Workers - TypeScript
export interface Env { AI: Ai;
}
export default { async fetch(request, env): Promise<Response> {
// Picture of a dog const exampleInputImage = await fetch( "https://pub-1fb693cb11cc46b2b2f656f51e015a2c.r2.dev/dog.png" );
// Mask of dog const exampleMask = await fetch( "https://pub-1fb693cb11cc46b2b2f656f51e015a2c.r2.dev/dog-mask.png" );
const inputs = { prompt: "Change to a lion", image: [...new Uint8Array(await exampleInputImage.arrayBuffer())], mask: [...new Uint8Array(await exampleMask.arrayBuffer())], };
const response = await env.AI.run( "@cf/runwayml/stable-diffusion-v1-5-inpainting", inputs );
return new Response(response, { headers: { "content-type": "image/png", }, }); },
} satisfies ExportedHandler<Env>;
curl
$ curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/runwayml/stable-diffusion-v1-5-inpainting \ -X POST \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -d '{ "prompt": "cyberpunk cat" }'
Response
The response is a binary PNG file.
API Schema
The following schema is based on JSON SchemaInput JSON Schema
Output JSON Schema