import { Community } from "modelslab";
const community = new Community(client.key);
// Text to Image
const image = await community.textToImage({
key: client.key,
prompt: "A futuristic city at night",
model_id: "stable-diffusion-v1-5",
width: 512,
height: 512,
samples: 1,
num_inference_steps: 20,
guidance_scale: 7.5,
});
// Image to Image
const imageToImage = await community.imageToImage({
key: client.key,
prompt: "A painting in Van Gogh style",
init_image: "base64-encoded-image",
model_id: "stable-diffusion-v1-5",
strength: 0.8,
});
// Inpainting (Fill masked areas)
const inpainting = await community.inpainting({
key: client.key,
prompt: "A red car",
init_image: "base64-encoded-image",
mask_image: "base64-encoded-mask",
model_id: "stable-diffusion-v1-5",
});
// ControlNet (Guided generation)
const controlnet = await community.controlnet({
key: client.key,
prompt: "A realistic portrait",
controlnet_model: "canny",
controlnet_conditioning_scale: 1.0,
model_id: "stable-diffusion-v1-5",
});