Only generate 1 iteration when seed fixed & variations disabled

This commit is contained in:
psychedelicious 2022-11-02 20:27:47 +11:00 committed by Lincoln Stein
parent 620cf84d3d
commit 7e55bdefce
3 changed files with 41 additions and 5 deletions

View File

@ -66,7 +66,8 @@ export const frontendToBackendParameters = (
const generationParameters: { [k: string]: any } = {
prompt,
iterations,
iterations:
shouldRandomizeSeed || shouldGenerateVariations ? iterations : 1,
steps,
cfg_scale: cfgScale,
threshold,
@ -76,7 +77,7 @@ export const frontendToBackendParameters = (
sampler_name: sampler,
seed,
progress_images: shouldDisplayInProgressType === 'full-res',
progress_latents: shouldDisplayInProgressType === 'latents'
progress_latents: shouldDisplayInProgressType === 'latents',
};
generationParameters.seed = shouldRandomizeSeed

View File

@ -1,13 +1,33 @@
import { createSelector } from '@reduxjs/toolkit';
import _ from 'lodash';
import React from 'react';
import { RootState, useAppDispatch, useAppSelector } from '../../../app/store';
import IAINumberInput from '../../../common/components/IAINumberInput';
import { setIterations } from '../optionsSlice';
import { mayGenerateMultipleImagesSelector } from '../optionsSelectors';
import { OptionsState, setIterations } from '../optionsSlice';
import { fontSize, inputWidth } from './MainOptions';
const mainIterationsSelector = createSelector(
[(state: RootState) => state.options, mayGenerateMultipleImagesSelector],
(options: OptionsState, mayGenerateMultipleImages) => {
const { iterations } = options;
return {
iterations,
mayGenerateMultipleImages,
};
},
{
memoizeOptions: {
resultEqualityCheck: _.isEqual,
},
}
);
export default function MainIterations() {
const dispatch = useAppDispatch();
const iterations = useAppSelector(
(state: RootState) => state.options.iterations
const { iterations, mayGenerateMultipleImages } = useAppSelector(
mainIterationsSelector
);
const handleChangeIterations = (v: number) => dispatch(setIterations(v));
@ -18,6 +38,7 @@ export default function MainIterations() {
step={1}
min={1}
max={9999}
isDisabled={!mayGenerateMultipleImages}
onChange={handleChangeIterations}
value={iterations}
width={inputWidth}

View File

@ -13,3 +13,17 @@ export const activeTabNameSelector = createSelector(
},
}
);
export const mayGenerateMultipleImagesSelector = createSelector(
(state: RootState) => state.options,
(options: OptionsState) => {
const { shouldRandomizeSeed, shouldGenerateVariations } = options;
return shouldRandomizeSeed || shouldGenerateVariations;
},
{
memoizeOptions: {
resultEqualityCheck: _.isEqual,
},
}
);