ubah kode import axios from axios;const handler = async m text command conn = const payloads = server_name rose prompt $text your imagination go here width 512 512-1024 height 768 512-1024
const axios = require("axios");
const handler = async (m, { text, command, conn }) => {
const payloads = {
server_name: "rose",
prompt: ${text}, // your imagination go here
width: 512, // 512-1024
height: 768, // 512-1024
steps: 25, // max 50 steps
model_id: "anything-v5", // default dream_shaper_
sampler: "Euler a", // 2M SDE karras
seed: null, // pass null or remove to get random seed
cfg: 7.5, // max 15<
image_num: 1, // max 4
negative_prompt: "ugly", // something you dont want to appear in the image
safety_checker: "no", // set "no" to replace nsfw image
/* Another optional parameter */
enhance_prompt: "yes", // if "yes" will add another prompt
multi_lingual: "yes", // pass "yes" if you want to use other than the English language
clip_skip: 2,
panorama: "no", // pass "yes" if you want a panorama image
lora_model: "more_details", // use loaded lora_model
hiresFix: "no", // otherwise pass "no"
lora_strength: 1, // default 1
embeddings_model: "",
webhook: null, // will send post about generating progress
};
m.reply("_Preparing Stable diffusion..._");
const { data } = await axios
.request({
baseURL: "https://api.itsrose.life",
url: "/image/diffusion/txt2img",
method: "POST",
params: {
apikey: `${global.rose}`,
},
data: payloads,
})
.catch((e) => e?.response);
const { status, message, result } = data;
if (!status) {
// something wrong with your payloads
return m.reply(message); // see the message
}
const { images, metadata, generation_time } = result;
const second = result.generation_time.toFixed();
const model = metadata.model_id;
const schedule = metadata.scheduler;
const w = metadata.W;
const h = metadata.H;
const cfg = metadata.guidance_scale;
const step = metadata.steps;
const seed = metadata.seed;
const streng = metadata.clip_skip;
const medata = `*Generating Time*: ${second} second
prompt: ${text} model_id: ${model} scheduler: ${schedule} W: ${w} H: ${h} guidance_scale: ${cfg} steps: ${step} seed: ${seed} clip_skip: ${streng}`; await m.reply(medata);
try {
for (const image of images) {
await new Promise((resolve) => {
setTimeout(async () => {
await conn.sendMessage(m.chat, { image: { url: image } });
resolve();
}, generation_time * 1000);
});
}
} catch {
m.reply(`Failed sending images : ${images.join(", ")}`);
}
};
handler.command = handler.help = ["txt2img"]; handler.tags = ["ai"]; handler.register = true; handler.limit = true;
module.exports = handler;
原文地址: https://www.cveoy.top/t/topic/jdvw 著作权归作者所有。请勿转载和采集!