fix(gui): use new grid seeds for every generation
This commit is contained in:
parent
8a97fca6d0
commit
90d1812dec
|
@ -39,6 +39,28 @@ export function replacePromptTokens(grid: PipelineGrid, params: Txt2ImgParams, c
|
|||
return result;
|
||||
}
|
||||
|
||||
export const MAX_SEED_SIZE = 32;
|
||||
export const MAX_SEED = (2**MAX_SEED_SIZE) - 1;
|
||||
|
||||
export function newSeed(): number {
|
||||
return Math.floor(Math.random() * MAX_SEED);
|
||||
}
|
||||
|
||||
export function replaceRandomSeeds(key: string, values: Array<number | string>): Array<number | string> {
|
||||
if (key !== 'seed') {
|
||||
return values;
|
||||
}
|
||||
|
||||
return values.map((it) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
||||
if (it === '-1' || it === -1) {
|
||||
return newSeed();
|
||||
}
|
||||
|
||||
return it;
|
||||
});
|
||||
}
|
||||
|
||||
// eslint-disable-next-line max-params
|
||||
export function makeTxt2ImgGridPipeline(grid: PipelineGrid, model: ModelParams, params: Txt2ImgParams, upscale?: UpscaleParams, highres?: HighresParams): ChainPipeline {
|
||||
const pipeline: ChainPipeline = {
|
||||
|
@ -53,10 +75,13 @@ export function makeTxt2ImgGridPipeline(grid: PipelineGrid, model: ModelParams,
|
|||
tiles: 8192,
|
||||
};
|
||||
|
||||
const rows = replaceRandomSeeds(grid.rows.parameter, grid.rows.values);
|
||||
const columns = replaceRandomSeeds(grid.columns.parameter, grid.columns.values);
|
||||
|
||||
let i = 0;
|
||||
|
||||
for (const row of grid.rows.values) {
|
||||
for (const column of grid.columns.values) {
|
||||
for (const row of rows) {
|
||||
for (const column of columns) {
|
||||
const prompt = replacePromptTokens(grid, params, column, row);
|
||||
|
||||
pipeline.stages.push({
|
||||
|
|
|
@ -99,14 +99,8 @@ export const EXPR_NUMBER_RANGE = /^(\d+)-(\d+)$/;
|
|||
|
||||
export function expandRanges(range: string): Array<string | number> {
|
||||
if (EXPR_STRICT_NUMBER.test(range)) {
|
||||
// entirely numeric, return without parsing
|
||||
// entirely numeric, return after parsing
|
||||
const val = parseInt(range, 10);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
||||
if (val === -1) {
|
||||
return [newSeed()];
|
||||
}
|
||||
|
||||
return [val];
|
||||
}
|
||||
|
||||
|
@ -124,13 +118,6 @@ export function expandRanges(range: string): Array<string | number> {
|
|||
return [];
|
||||
}
|
||||
|
||||
export const MAX_SEED_SIZE = 32;
|
||||
export const MAX_SEED = (2**MAX_SEED_SIZE) - 1;
|
||||
|
||||
export function newSeed(): number {
|
||||
return Math.floor(Math.random() * MAX_SEED);
|
||||
}
|
||||
|
||||
export const VARIABLE_PARAMETERS = ['prompt', 'negativePrompt', 'seed', 'steps', 'cfg', 'scheduler', 'eta', 'token'];
|
||||
export const STRING_PARAMETERS = ['prompt', 'negativePrompt', 'scheduler', 'token'];
|
||||
|
||||
|
|
Loading…
Reference in New Issue