Add Save Intermediates Step Count

For accurate mode only.

Co-Authored-By: Richard Macarthy <richardmacarthy@protonmail.com>
This commit is contained in:
blessedcoolant 2022-11-03 02:59:11 +13:00 committed by Lincoln Stein
parent 6173e3e9ca
commit 383905d5d2
4 changed files with 52 additions and 15 deletions

View File

@ -616,7 +616,7 @@ class InvokeAIWebServer:
if ( if (
generation_parameters["progress_images"] generation_parameters["progress_images"]
and step % 5 == 0 and step % generation_parameters['save_intermediates'] == 0
and step < generation_parameters["steps"] - 1 and step < generation_parameters["steps"] - 1
): ):
image = self.generate.sample_to_image(sample) image = self.generate.sample_to_image(sample)

View File

@ -62,7 +62,8 @@ export const frontendToBackendParameters = (
shouldRandomizeSeed, shouldRandomizeSeed,
} = optionsState; } = optionsState;
const { shouldDisplayInProgressType } = systemState; const { shouldDisplayInProgressType, saveIntermediatesInterval } =
systemState;
const generationParameters: { [k: string]: any } = { const generationParameters: { [k: string]: any } = {
prompt, prompt,
@ -78,6 +79,7 @@ export const frontendToBackendParameters = (
seed, seed,
progress_images: shouldDisplayInProgressType === 'full-res', progress_images: shouldDisplayInProgressType === 'full-res',
progress_latents: shouldDisplayInProgressType === 'latents', progress_latents: shouldDisplayInProgressType === 'latents',
save_intermediates: saveIntermediatesInterval,
}; };
generationParameters.seed = shouldRandomizeSeed generationParameters.seed = shouldRandomizeSeed

View File

@ -19,6 +19,7 @@ import { RootState, useAppDispatch, useAppSelector } from '../../../app/store';
import { persistor } from '../../../main'; import { persistor } from '../../../main';
import { import {
InProgressImageType, InProgressImageType,
setSaveIntermediatesInterval,
setShouldConfirmOnDelete, setShouldConfirmOnDelete,
setShouldDisplayGuides, setShouldDisplayGuides,
setShouldDisplayInProgressType, setShouldDisplayInProgressType,
@ -28,6 +29,7 @@ import ModelList from './ModelList';
import { IN_PROGRESS_IMAGE_TYPES } from '../../../app/constants'; import { IN_PROGRESS_IMAGE_TYPES } from '../../../app/constants';
import IAISwitch from '../../../common/components/IAISwitch'; import IAISwitch from '../../../common/components/IAISwitch';
import IAISelect from '../../../common/components/IAISelect'; import IAISelect from '../../../common/components/IAISelect';
import IAINumberInput from '../../../common/components/IAINumberInput';
const systemSelector = createSelector( const systemSelector = createSelector(
(state: RootState) => state.system, (state: RootState) => state.system,
@ -64,6 +66,12 @@ type SettingsModalProps = {
const SettingsModal = ({ children }: SettingsModalProps) => { const SettingsModal = ({ children }: SettingsModalProps) => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const saveIntermediatesInterval = useAppSelector(
(state: RootState) => state.system.saveIntermediatesInterval
);
const steps = useAppSelector((state: RootState) => state.options.steps);
const { const {
isOpen: isSettingsModalOpen, isOpen: isSettingsModalOpen,
onOpen: onSettingsModalOpen, onOpen: onSettingsModalOpen,
@ -93,6 +101,12 @@ const SettingsModal = ({ children }: SettingsModalProps) => {
}); });
}; };
const handleChangeIntermediateSteps = (value: number) => {
if (value > steps) value = steps;
if (value < 1) value = 1;
dispatch(setSaveIntermediatesInterval(value));
};
return ( return (
<> <>
{cloneElement(children, { {cloneElement(children, {
@ -109,20 +123,35 @@ const SettingsModal = ({ children }: SettingsModalProps) => {
<div className="settings-modal-item"> <div className="settings-modal-item">
<ModelList /> <ModelList />
</div> </div>
<IAISelect <div
styleClass="settings-modal-item" className="settings-modal-item"
label={'Display In-Progress Images'} style={{ gridAutoFlow: 'row', rowGap: '0.5rem' }}
validValues={IN_PROGRESS_IMAGE_TYPES} >
value={shouldDisplayInProgressType} <IAISelect
onChange={(e: ChangeEvent<HTMLSelectElement>) => label={'Display In-Progress Images'}
dispatch( validValues={IN_PROGRESS_IMAGE_TYPES}
setShouldDisplayInProgressType( value={shouldDisplayInProgressType}
e.target.value as InProgressImageType onChange={(e: ChangeEvent<HTMLSelectElement>) =>
dispatch(
setShouldDisplayInProgressType(
e.target.value as InProgressImageType
)
) )
) }
} />
/> {shouldDisplayInProgressType === 'full-res' && (
<IAINumberInput
label="Save images every n steps"
min={1}
max={steps}
step={1}
onChange={handleChangeIntermediateSteps}
value={saveIntermediatesInterval}
width="auto"
textAlign="center"
/>
)}
</div>
<IAISwitch <IAISwitch
styleClass="settings-modal-item" styleClass="settings-modal-item"
label={'Confirm on Delete'} label={'Confirm on Delete'}

View File

@ -43,6 +43,7 @@ export interface SystemState
shouldDisplayGuides: boolean; shouldDisplayGuides: boolean;
wasErrorSeen: boolean; wasErrorSeen: boolean;
isCancelable: boolean; isCancelable: boolean;
saveIntermediatesInterval: number;
} }
const initialSystemState: SystemState = { const initialSystemState: SystemState = {
@ -72,6 +73,7 @@ const initialSystemState: SystemState = {
hasError: false, hasError: false,
wasErrorSeen: true, wasErrorSeen: true,
isCancelable: true, isCancelable: true,
saveIntermediatesInterval: 5,
}; };
export const systemSlice = createSlice({ export const systemSlice = createSlice({
@ -186,6 +188,9 @@ export const systemSlice = createSlice({
state.isProcessing = true; state.isProcessing = true;
state.currentStatusHasSteps = false; state.currentStatusHasSteps = false;
}, },
setSaveIntermediatesInterval: (state, action: PayloadAction<number>) => {
state.saveIntermediatesInterval = action.payload;
},
}, },
}); });
@ -208,6 +213,7 @@ export const {
setModelList, setModelList,
setIsCancelable, setIsCancelable,
modelChangeRequested, modelChangeRequested,
setSaveIntermediatesInterval,
} = systemSlice.actions; } = systemSlice.actions;
export default systemSlice.reducer; export default systemSlice.reducer;