mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Add Hi Res Strength Slider
This commit is contained in:
parent
28b40bebbe
commit
f52b233205
@ -24,6 +24,7 @@
|
|||||||
"otherOptions": "Other Options",
|
"otherOptions": "Other Options",
|
||||||
"seamlessTiling": "Seamless Tiling",
|
"seamlessTiling": "Seamless Tiling",
|
||||||
"hiresOptim": "High Res Optimization",
|
"hiresOptim": "High Res Optimization",
|
||||||
|
"hiresStrength": "High Res Strength",
|
||||||
"imageFit": "Fit Initial Image To Output Size",
|
"imageFit": "Fit Initial Image To Output Size",
|
||||||
"codeformerFidelity": "Fidelity",
|
"codeformerFidelity": "Fidelity",
|
||||||
"seamSize": "Seam Size",
|
"seamSize": "Seam Size",
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
"otherOptions": "Other Options",
|
"otherOptions": "Other Options",
|
||||||
"seamlessTiling": "Seamless Tiling",
|
"seamlessTiling": "Seamless Tiling",
|
||||||
"hiresOptim": "High Res Optimization",
|
"hiresOptim": "High Res Optimization",
|
||||||
|
"hiresStrength": "High Res Strength",
|
||||||
"imageFit": "Fit Initial Image To Output Size",
|
"imageFit": "Fit Initial Image To Output Size",
|
||||||
"codeformerFidelity": "Fidelity",
|
"codeformerFidelity": "Fidelity",
|
||||||
"seamSize": "Seam Size",
|
"seamSize": "Seam Size",
|
||||||
|
@ -100,6 +100,7 @@ export const frontendToBackendParameters = (
|
|||||||
facetoolType,
|
facetoolType,
|
||||||
height,
|
height,
|
||||||
hiresFix,
|
hiresFix,
|
||||||
|
hiresStrength,
|
||||||
img2imgStrength,
|
img2imgStrength,
|
||||||
infillMethod,
|
infillMethod,
|
||||||
initialImage,
|
initialImage,
|
||||||
@ -169,6 +170,8 @@ export const frontendToBackendParameters = (
|
|||||||
generationParameters.seamless = seamless;
|
generationParameters.seamless = seamless;
|
||||||
generationParameters.hires_fix = hiresFix;
|
generationParameters.hires_fix = hiresFix;
|
||||||
|
|
||||||
|
if (hiresFix) generationParameters.strength = hiresStrength;
|
||||||
|
|
||||||
if (shouldRunESRGAN) {
|
if (shouldRunESRGAN) {
|
||||||
esrganParameters = {
|
esrganParameters = {
|
||||||
level: upscalingLevel,
|
level: upscalingLevel,
|
||||||
|
@ -1,10 +1,53 @@
|
|||||||
import { Flex } from '@chakra-ui/react';
|
import { Flex } from '@chakra-ui/react';
|
||||||
import { ChangeEvent } from 'react';
|
import { ChangeEvent } from 'react';
|
||||||
import { RootState } from 'app/store';
|
import type { RootState } from 'app/store';
|
||||||
import { useAppDispatch, useAppSelector } from 'app/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/storeHooks';
|
||||||
import IAISwitch from 'common/components/IAISwitch';
|
import IAISwitch from 'common/components/IAISwitch';
|
||||||
import { setHiresFix } from 'features/options/store/optionsSlice';
|
import {
|
||||||
|
setHiresFix,
|
||||||
|
setHiresStrength,
|
||||||
|
} from 'features/options/store/optionsSlice';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import IAISlider from 'common/components/IAISlider';
|
||||||
|
|
||||||
|
function HighResStrength() {
|
||||||
|
const hiresFix = useAppSelector((state: RootState) => state.options.hiresFix);
|
||||||
|
const hiresStrength = useAppSelector(
|
||||||
|
(state: RootState) => state.options.hiresStrength
|
||||||
|
);
|
||||||
|
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const handleHiresStrength = (v: number) => {
|
||||||
|
dispatch(setHiresStrength(v));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleHiResStrengthReset = () => {
|
||||||
|
dispatch(setHiresStrength(0.75));
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<IAISlider
|
||||||
|
label={t('options:hiresStrength')}
|
||||||
|
step={0.01}
|
||||||
|
min={0.01}
|
||||||
|
max={0.99}
|
||||||
|
onChange={handleHiresStrength}
|
||||||
|
value={hiresStrength}
|
||||||
|
isInteger={false}
|
||||||
|
withInput
|
||||||
|
withSliderMarks
|
||||||
|
inputWidth={'5.5rem'}
|
||||||
|
withReset
|
||||||
|
handleReset={handleHiResStrengthReset}
|
||||||
|
isSliderDisabled={!hiresFix}
|
||||||
|
isInputDisabled={!hiresFix}
|
||||||
|
isResetDisabled={!hiresFix}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hires Fix Toggle
|
* Hires Fix Toggle
|
||||||
@ -27,6 +70,7 @@ const HiresOptions = () => {
|
|||||||
isChecked={hiresFix}
|
isChecked={hiresFix}
|
||||||
onChange={handleChangeHiresFix}
|
onChange={handleChangeHiresFix}
|
||||||
/>
|
/>
|
||||||
|
<HighResStrength />
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -20,6 +20,7 @@ export interface OptionsState {
|
|||||||
facetoolType: FacetoolType;
|
facetoolType: FacetoolType;
|
||||||
height: number;
|
height: number;
|
||||||
hiresFix: boolean;
|
hiresFix: boolean;
|
||||||
|
hiresStrength: number;
|
||||||
img2imgStrength: number;
|
img2imgStrength: number;
|
||||||
infillMethod: string;
|
infillMethod: string;
|
||||||
initialImage?: InvokeAI.Image | string; // can be an Image or url
|
initialImage?: InvokeAI.Image | string; // can be an Image or url
|
||||||
@ -71,6 +72,7 @@ const initialOptionsState: OptionsState = {
|
|||||||
facetoolType: 'gfpgan',
|
facetoolType: 'gfpgan',
|
||||||
height: 512,
|
height: 512,
|
||||||
hiresFix: false,
|
hiresFix: false,
|
||||||
|
hiresStrength: 0.75,
|
||||||
img2imgStrength: 0.75,
|
img2imgStrength: 0.75,
|
||||||
infillMethod: 'patchmatch',
|
infillMethod: 'patchmatch',
|
||||||
isLightBoxOpen: false,
|
isLightBoxOpen: false,
|
||||||
@ -189,6 +191,9 @@ export const optionsSlice = createSlice({
|
|||||||
setHiresFix: (state, action: PayloadAction<boolean>) => {
|
setHiresFix: (state, action: PayloadAction<boolean>) => {
|
||||||
state.hiresFix = action.payload;
|
state.hiresFix = action.payload;
|
||||||
},
|
},
|
||||||
|
setHiresStrength: (state, action: PayloadAction<number>) => {
|
||||||
|
state.hiresStrength = action.payload;
|
||||||
|
},
|
||||||
setShouldFitToWidthHeight: (state, action: PayloadAction<boolean>) => {
|
setShouldFitToWidthHeight: (state, action: PayloadAction<boolean>) => {
|
||||||
state.shouldFitToWidthHeight = action.payload;
|
state.shouldFitToWidthHeight = action.payload;
|
||||||
},
|
},
|
||||||
@ -459,6 +464,7 @@ export const {
|
|||||||
setFacetoolType,
|
setFacetoolType,
|
||||||
setHeight,
|
setHeight,
|
||||||
setHiresFix,
|
setHiresFix,
|
||||||
|
setHiresStrength,
|
||||||
setImg2imgStrength,
|
setImg2imgStrength,
|
||||||
setInfillMethod,
|
setInfillMethod,
|
||||||
setInitialImage,
|
setInitialImage,
|
||||||
|
Loading…
Reference in New Issue
Block a user