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

View File

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