mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Add frontend UI for denoise_str for ESRGAN
This commit is contained in:
parent
9601febef8
commit
83ecda977c
@ -20,6 +20,7 @@
|
|||||||
"upscaling": "Upscaling",
|
"upscaling": "Upscaling",
|
||||||
"upscale": "Upscale",
|
"upscale": "Upscale",
|
||||||
"upscaleImage": "Upscale Image",
|
"upscaleImage": "Upscale Image",
|
||||||
|
"denoisingStrength": "Denoising Strength",
|
||||||
"scale": "Scale",
|
"scale": "Scale",
|
||||||
"otherOptions": "Other Options",
|
"otherOptions": "Other Options",
|
||||||
"seamlessTiling": "Seamless Tiling",
|
"seamlessTiling": "Seamless Tiling",
|
||||||
|
@ -93,11 +93,15 @@ const makeSocketIOEmitters = (
|
|||||||
dispatch(setIsProcessing(true));
|
dispatch(setIsProcessing(true));
|
||||||
|
|
||||||
const {
|
const {
|
||||||
postprocessing: { upscalingLevel, upscalingStrength },
|
postprocessing: {
|
||||||
|
upscalingLevel,
|
||||||
|
upscalingDenoising,
|
||||||
|
upscalingStrength,
|
||||||
|
},
|
||||||
} = getState();
|
} = getState();
|
||||||
|
|
||||||
const esrganParameters = {
|
const esrganParameters = {
|
||||||
upscale: [upscalingLevel, upscalingStrength],
|
upscale: [upscalingLevel, upscalingDenoising, upscalingStrength],
|
||||||
};
|
};
|
||||||
socketio.emit('runPostprocessing', imageToProcess, {
|
socketio.emit('runPostprocessing', imageToProcess, {
|
||||||
type: 'esrgan',
|
type: 'esrgan',
|
||||||
|
@ -69,6 +69,7 @@ export type BackendGenerationParameters = {
|
|||||||
|
|
||||||
export type BackendEsrGanParameters = {
|
export type BackendEsrGanParameters = {
|
||||||
level: UpscalingLevel;
|
level: UpscalingLevel;
|
||||||
|
denoise_str: number;
|
||||||
strength: number;
|
strength: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -111,13 +112,12 @@ export const frontendToBackendParameters = (
|
|||||||
shouldRunFacetool,
|
shouldRunFacetool,
|
||||||
upscalingLevel,
|
upscalingLevel,
|
||||||
upscalingStrength,
|
upscalingStrength,
|
||||||
|
upscalingDenoising,
|
||||||
} = postprocessingState;
|
} = postprocessingState;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
cfgScale,
|
cfgScale,
|
||||||
|
|
||||||
height,
|
height,
|
||||||
|
|
||||||
img2imgStrength,
|
img2imgStrength,
|
||||||
infillMethod,
|
infillMethod,
|
||||||
initialImage,
|
initialImage,
|
||||||
@ -136,11 +136,9 @@ export const frontendToBackendParameters = (
|
|||||||
shouldFitToWidthHeight,
|
shouldFitToWidthHeight,
|
||||||
shouldGenerateVariations,
|
shouldGenerateVariations,
|
||||||
shouldRandomizeSeed,
|
shouldRandomizeSeed,
|
||||||
|
|
||||||
steps,
|
steps,
|
||||||
threshold,
|
threshold,
|
||||||
tileSize,
|
tileSize,
|
||||||
|
|
||||||
variationAmount,
|
variationAmount,
|
||||||
width,
|
width,
|
||||||
} = generationState;
|
} = generationState;
|
||||||
@ -190,6 +188,7 @@ export const frontendToBackendParameters = (
|
|||||||
if (shouldRunESRGAN) {
|
if (shouldRunESRGAN) {
|
||||||
esrganParameters = {
|
esrganParameters = {
|
||||||
level: upscalingLevel,
|
level: upscalingLevel,
|
||||||
|
denoise_str: upscalingDenoising,
|
||||||
strength: upscalingStrength,
|
strength: upscalingStrength,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
.upscale-settings {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: auto 1fr;
|
|
||||||
column-gap: 1rem;
|
|
||||||
}
|
|
@ -1,6 +1,7 @@
|
|||||||
import { useAppDispatch, useAppSelector } from 'app/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/storeHooks';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
setUpscalingDenoising,
|
||||||
setUpscalingLevel,
|
setUpscalingLevel,
|
||||||
setUpscalingStrength,
|
setUpscalingStrength,
|
||||||
UpscalingLevel,
|
UpscalingLevel,
|
||||||
@ -8,20 +9,25 @@ import {
|
|||||||
|
|
||||||
import { createSelector } from '@reduxjs/toolkit';
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
import { UPSCALING_LEVELS } from 'app/constants';
|
import { UPSCALING_LEVELS } from 'app/constants';
|
||||||
import IAINumberInput from 'common/components/IAINumberInput';
|
|
||||||
import IAISelect from 'common/components/IAISelect';
|
import IAISelect from 'common/components/IAISelect';
|
||||||
import { postprocessingSelector } from 'features/parameters/store/postprocessingSelectors';
|
import { postprocessingSelector } from 'features/parameters/store/postprocessingSelectors';
|
||||||
import { systemSelector } from 'features/system/store/systemSelectors';
|
import { systemSelector } from 'features/system/store/systemSelectors';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
import { ChangeEvent } from 'react';
|
import { ChangeEvent } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import IAISlider from 'common/components/IAISlider';
|
||||||
|
import { Flex } from '@chakra-ui/react';
|
||||||
|
|
||||||
const parametersSelector = createSelector(
|
const parametersSelector = createSelector(
|
||||||
[postprocessingSelector, systemSelector],
|
[postprocessingSelector, systemSelector],
|
||||||
|
|
||||||
({ upscalingLevel, upscalingStrength }, { isESRGANAvailable }) => {
|
(
|
||||||
|
{ upscalingLevel, upscalingStrength, upscalingDenoising },
|
||||||
|
{ isESRGANAvailable }
|
||||||
|
) => {
|
||||||
return {
|
return {
|
||||||
upscalingLevel,
|
upscalingLevel,
|
||||||
|
upscalingDenoising,
|
||||||
upscalingStrength,
|
upscalingStrength,
|
||||||
isESRGANAvailable,
|
isESRGANAvailable,
|
||||||
};
|
};
|
||||||
@ -38,8 +44,12 @@ const parametersSelector = createSelector(
|
|||||||
*/
|
*/
|
||||||
const UpscaleSettings = () => {
|
const UpscaleSettings = () => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { upscalingLevel, upscalingStrength, isESRGANAvailable } =
|
const {
|
||||||
useAppSelector(parametersSelector);
|
upscalingLevel,
|
||||||
|
upscalingStrength,
|
||||||
|
upscalingDenoising,
|
||||||
|
isESRGANAvailable,
|
||||||
|
} = useAppSelector(parametersSelector);
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@ -49,7 +59,7 @@ const UpscaleSettings = () => {
|
|||||||
const handleChangeStrength = (v: number) => dispatch(setUpscalingStrength(v));
|
const handleChangeStrength = (v: number) => dispatch(setUpscalingStrength(v));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="upscale-settings">
|
<Flex flexDir="column" rowGap="1rem" minWidth="20rem">
|
||||||
<IAISelect
|
<IAISelect
|
||||||
isDisabled={!isESRGANAvailable}
|
isDisabled={!isESRGANAvailable}
|
||||||
label={t('parameters:scale')}
|
label={t('parameters:scale')}
|
||||||
@ -57,17 +67,39 @@ const UpscaleSettings = () => {
|
|||||||
onChange={handleChangeLevel}
|
onChange={handleChangeLevel}
|
||||||
validValues={UPSCALING_LEVELS}
|
validValues={UPSCALING_LEVELS}
|
||||||
/>
|
/>
|
||||||
<IAINumberInput
|
<IAISlider
|
||||||
isDisabled={!isESRGANAvailable}
|
label={t('parameters:denoisingStrength')}
|
||||||
label={t('parameters:strength')}
|
value={upscalingDenoising}
|
||||||
step={0.05}
|
|
||||||
min={0}
|
min={0}
|
||||||
max={1}
|
max={1}
|
||||||
onChange={handleChangeStrength}
|
step={0.01}
|
||||||
value={upscalingStrength}
|
onChange={(v) => {
|
||||||
isInteger={false}
|
dispatch(setUpscalingDenoising(v));
|
||||||
|
}}
|
||||||
|
handleReset={() => dispatch(setUpscalingDenoising(0.75))}
|
||||||
|
withSliderMarks
|
||||||
|
withInput
|
||||||
|
withReset
|
||||||
|
isSliderDisabled={!isESRGANAvailable}
|
||||||
|
isInputDisabled={!isESRGANAvailable}
|
||||||
|
isResetDisabled={!isESRGANAvailable}
|
||||||
/>
|
/>
|
||||||
</div>
|
<IAISlider
|
||||||
|
label={`${t('parameters:upscale')} ${t('parameters:strength')}`}
|
||||||
|
value={upscalingStrength}
|
||||||
|
min={0}
|
||||||
|
max={1}
|
||||||
|
step={0.05}
|
||||||
|
onChange={handleChangeStrength}
|
||||||
|
handleReset={() => dispatch(setUpscalingStrength(0.75))}
|
||||||
|
withSliderMarks
|
||||||
|
withInput
|
||||||
|
withReset
|
||||||
|
isSliderDisabled={!isESRGANAvailable}
|
||||||
|
isInputDisabled={!isESRGANAvailable}
|
||||||
|
isResetDisabled={!isESRGANAvailable}
|
||||||
|
/>
|
||||||
|
</Flex>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ export interface PostprocessingState {
|
|||||||
shouldRunESRGAN: boolean;
|
shouldRunESRGAN: boolean;
|
||||||
shouldRunFacetool: boolean;
|
shouldRunFacetool: boolean;
|
||||||
upscalingLevel: UpscalingLevel;
|
upscalingLevel: UpscalingLevel;
|
||||||
|
upscalingDenoising: number;
|
||||||
upscalingStrength: number;
|
upscalingStrength: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ const initialPostprocessingState: PostprocessingState = {
|
|||||||
shouldRunESRGAN: false,
|
shouldRunESRGAN: false,
|
||||||
shouldRunFacetool: false,
|
shouldRunFacetool: false,
|
||||||
upscalingLevel: 4,
|
upscalingLevel: 4,
|
||||||
|
upscalingDenoising: 0.75,
|
||||||
upscalingStrength: 0.75,
|
upscalingStrength: 0.75,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -47,6 +49,9 @@ export const postprocessingSlice = createSlice({
|
|||||||
setUpscalingLevel: (state, action: PayloadAction<UpscalingLevel>) => {
|
setUpscalingLevel: (state, action: PayloadAction<UpscalingLevel>) => {
|
||||||
state.upscalingLevel = action.payload;
|
state.upscalingLevel = action.payload;
|
||||||
},
|
},
|
||||||
|
setUpscalingDenoising: (state, action: PayloadAction<number>) => {
|
||||||
|
state.upscalingDenoising = action.payload;
|
||||||
|
},
|
||||||
setUpscalingStrength: (state, action: PayloadAction<number>) => {
|
setUpscalingStrength: (state, action: PayloadAction<number>) => {
|
||||||
state.upscalingStrength = action.payload;
|
state.upscalingStrength = action.payload;
|
||||||
},
|
},
|
||||||
@ -88,6 +93,7 @@ export const {
|
|||||||
setShouldRunESRGAN,
|
setShouldRunESRGAN,
|
||||||
setShouldRunFacetool,
|
setShouldRunFacetool,
|
||||||
setUpscalingLevel,
|
setUpscalingLevel,
|
||||||
|
setUpscalingDenoising,
|
||||||
setUpscalingStrength,
|
setUpscalingStrength,
|
||||||
} = postprocessingSlice.actions;
|
} = postprocessingSlice.actions;
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
@use '../features/parameters/components/ProcessButtons/ProcessButtons.scss';
|
@use '../features/parameters/components/ProcessButtons/ProcessButtons.scss';
|
||||||
@use '../features/parameters/components/MainParameters/MainParameters.scss';
|
@use '../features/parameters/components/MainParameters/MainParameters.scss';
|
||||||
@use '../features/parameters/components/AccordionItems/AdvancedSettings.scss';
|
@use '../features/parameters/components/AccordionItems/AdvancedSettings.scss';
|
||||||
@use '../features/parameters/components/AdvancedParameters/Upscale/UpscaleSettings.scss';
|
|
||||||
@use '../features/parameters/components/AdvancedParameters/Canvas/BoundingBox/BoundingBoxSettings.scss';
|
@use '../features/parameters/components/AdvancedParameters/Canvas/BoundingBox/BoundingBoxSettings.scss';
|
||||||
|
|
||||||
// gallery
|
// gallery
|
||||||
|
Loading…
x
Reference in New Issue
Block a user