Add SD seed control

This commit is contained in:
Cohee
2024-05-29 23:29:45 +03:00
parent 31eb0235c2
commit 4eb6657b51
5 changed files with 33 additions and 5 deletions

View File

@ -326,6 +326,7 @@ router.post('/generate-image', jsonParser, async (request, response) => {
height: request.body.height,
karras: Boolean(request.body.karras),
clip_skip: request.body.clip_skip,
seed: request.body.seed >= 0 ? String(request.body.seed) : undefined,
n: 1,
},
r2: false,

View File

@ -255,7 +255,7 @@ router.post('/generate-image', jsonParser, async (request, response) => {
height: request.body.height ?? 512,
width: request.body.width ?? 512,
scale: request.body.scale ?? 9,
seed: Math.floor(Math.random() * 9999999999),
seed: request.body.seed >= 0 ? request.body.seed : Math.floor(Math.random() * 9999999999),
sampler: request.body.sampler ?? 'k_dpmpp_2m',
steps: request.body.steps ?? 28,
n_samples: 1,

View File

@ -608,8 +608,10 @@ together.post('/generate', jsonParser, async (request, response) => {
model: request.body.model,
steps: request.body.steps,
n: 1,
seed: Math.floor(Math.random() * 10_000_000), // Limited to 10000 on playground, works fine with more.
sessionKey: getHexString(40), // Don't know if that's supposed to be random or not. It works either way.
// Limited to 10000 on playground, works fine with more.
seed: request.body.seed >= 0 ? request.body.seed : Math.floor(Math.random() * 10_000_000),
// Don't know if that's supposed to be random or not. It works either way.
sessionKey: getHexString(40),
}),
headers: {
'Content-Type': 'application/json',
@ -736,7 +738,7 @@ pollinations.post('/generate', jsonParser, async (request, response) => {
const params = new URLSearchParams({
model: String(request.body.model),
negative_prompt: String(request.body.negative_prompt),
seed: String(Math.floor(Math.random() * 10_000_000)),
seed: String(request.body.seed >= 0 ? request.body.seed : Math.floor(Math.random() * 10_000_000)),
enhance: String(request.body.enhance ?? false),
refine: String(request.body.refine ?? false),
width: String(request.body.width ?? 1024),