cjwbw / stable-diffusion

stable-diffusion with negative prompts, more scheduler

  • Public
  • 65.4K runs
  • A100 (80GB)
  • GitHub
  • License
Iterate in playground

Run cjwbw/stable-diffusion with an API

Use one of our client libraries to get started quickly.

Set the REPLICATE_API_TOKEN environment variable

export REPLICATE_API_TOKEN=<paste-your-token-here>

Learn more about authentication

Install Replicate’s Node.js client library

npm install replicate
Learn more about setup

Run cjwbw/stable-diffusion using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.

import { writeFile } from "fs/promises";
import Replicate from "replicate";
const replicate = new Replicate();

const input = {
    width: "512",
    height: "512",
    prompt: "Ragdoll cat king wearing a golden crown, intricate, elegant, highly detailed, centered, digital painting, artstation, concept art, smooth, sharp focus, illustration, artgerm, Tomasz Alen Kopera, Peter Mohrbacher, donato giancola, Joseph Christian Leyendecker, WLOP, Boris Vallejo",
    scheduler: "K_EULER_ANCESTRAL",
    num_inference_steps: "30"
};

const output = await replicate.run("cjwbw/stable-diffusion:b8f1324c04d97f36ea5b717eb1bd4fd00bc418f072b4bf167172708e7131d1b1", { input });

// To access the file URLs:
console.log(output[0].url());
//=> "https://replicate.delivery/.../output_0.png"

// To write the files to disk:
for (const [index, item] of Object.entries(output)) {
  await writeFile(`output_${index}.png`, item);
}
//=> output_0.png written to disk
Learn more