mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): add refiner cfg scale & steps defaults & marks
This commit is contained in:
parent
f4ea495d23
commit
4e9841c924
@ -1,3 +1,5 @@
|
|||||||
|
import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
|
||||||
|
import { stateSelector } from 'app/store/store';
|
||||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
import { InvControl } from 'common/components/InvControl/InvControl';
|
import { InvControl } from 'common/components/InvControl/InvControl';
|
||||||
import { InvSlider } from 'common/components/InvSlider/InvSlider';
|
import { InvSlider } from 'common/components/InvSlider/InvSlider';
|
||||||
@ -5,26 +7,50 @@ import { setRefinerCFGScale } from 'features/sdxl/store/sdxlSlice';
|
|||||||
import { memo, useCallback } from 'react';
|
import { memo, useCallback } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
const selector = createMemoizedSelector([stateSelector], ({ config }) => {
|
||||||
|
const { min, inputMax, sliderMax, coarseStep, fineStep, initial } =
|
||||||
|
config.sd.guidance;
|
||||||
|
|
||||||
|
return {
|
||||||
|
marks: [min, Math.floor(sliderMax / 2), sliderMax],
|
||||||
|
min,
|
||||||
|
inputMax,
|
||||||
|
sliderMax,
|
||||||
|
coarseStep,
|
||||||
|
fineStep,
|
||||||
|
initial,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const ParamSDXLRefinerCFGScale = () => {
|
const ParamSDXLRefinerCFGScale = () => {
|
||||||
const refinerCFGScale = useAppSelector((state) => state.sdxl.refinerCFGScale);
|
const refinerCFGScale = useAppSelector((state) => state.sdxl.refinerCFGScale);
|
||||||
|
const { marks, min, inputMax, sliderMax, coarseStep, fineStep, initial } =
|
||||||
|
useAppSelector(selector);
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const handleChange = useCallback(
|
const onChange = useCallback(
|
||||||
(v: number) => dispatch(setRefinerCFGScale(v)),
|
(v: number) => dispatch(setRefinerCFGScale(v)),
|
||||||
[dispatch]
|
[dispatch]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const onReset = useCallback(() => {
|
||||||
|
dispatch(setRefinerCFGScale(initial));
|
||||||
|
}, [dispatch, initial]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InvControl label={t('sdxl.cfgScale')}>
|
<InvControl label={t('sdxl.cfgScale')}>
|
||||||
<InvSlider
|
<InvSlider
|
||||||
value={refinerCFGScale}
|
value={refinerCFGScale}
|
||||||
min={1}
|
min={min}
|
||||||
max={200}
|
max={sliderMax}
|
||||||
step={0.5}
|
step={coarseStep}
|
||||||
fineStep={0.1}
|
fineStep={fineStep}
|
||||||
onChange={handleChange}
|
onChange={onChange}
|
||||||
|
onReset={onReset}
|
||||||
withNumberInput
|
withNumberInput
|
||||||
|
numberInputMax={inputMax}
|
||||||
|
marks={marks}
|
||||||
/>
|
/>
|
||||||
</InvControl>
|
</InvControl>
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
|
||||||
|
import { stateSelector } from 'app/store/store';
|
||||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
import { InvControl } from 'common/components/InvControl/InvControl';
|
import { InvControl } from 'common/components/InvControl/InvControl';
|
||||||
import { InvSlider } from 'common/components/InvSlider/InvSlider';
|
import { InvSlider } from 'common/components/InvSlider/InvSlider';
|
||||||
@ -5,26 +7,51 @@ import { setRefinerSteps } from 'features/sdxl/store/sdxlSlice';
|
|||||||
import { memo, useCallback } from 'react';
|
import { memo, useCallback } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
const selector = createMemoizedSelector([stateSelector], ({ config }) => {
|
||||||
|
const { initial, min, sliderMax, inputMax, fineStep, coarseStep } =
|
||||||
|
config.sd.steps;
|
||||||
|
|
||||||
|
return {
|
||||||
|
marks: [min, Math.floor(sliderMax / 2), sliderMax],
|
||||||
|
initial,
|
||||||
|
min,
|
||||||
|
sliderMax,
|
||||||
|
inputMax,
|
||||||
|
step: coarseStep,
|
||||||
|
fineStep,
|
||||||
|
};
|
||||||
|
});
|
||||||
const ParamSDXLRefinerSteps = () => {
|
const ParamSDXLRefinerSteps = () => {
|
||||||
|
const { initial, min, sliderMax, inputMax, step, fineStep, marks } =
|
||||||
|
useAppSelector(selector);
|
||||||
const refinerSteps = useAppSelector((state) => state.sdxl.refinerSteps);
|
const refinerSteps = useAppSelector((state) => state.sdxl.refinerSteps);
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const handleChange = useCallback(
|
|
||||||
|
const onChange = useCallback(
|
||||||
(v: number) => {
|
(v: number) => {
|
||||||
dispatch(setRefinerSteps(v));
|
dispatch(setRefinerSteps(v));
|
||||||
},
|
},
|
||||||
[dispatch]
|
[dispatch]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const onReset = useCallback(() => {
|
||||||
|
dispatch(setRefinerSteps(initial));
|
||||||
|
}, [dispatch, initial]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<InvControl label={t('sdxl.steps')}>
|
<InvControl label={t('sdxl.steps')}>
|
||||||
<InvSlider
|
<InvSlider
|
||||||
min={1}
|
|
||||||
max={100}
|
|
||||||
step={1}
|
|
||||||
onChange={handleChange}
|
|
||||||
value={refinerSteps}
|
value={refinerSteps}
|
||||||
|
min={min}
|
||||||
|
max={sliderMax}
|
||||||
|
step={step}
|
||||||
|
fineStep={fineStep}
|
||||||
|
onChange={onChange}
|
||||||
|
onReset={onReset}
|
||||||
withNumberInput
|
withNumberInput
|
||||||
|
marks={marks}
|
||||||
|
numberInputMax={inputMax}
|
||||||
/>
|
/>
|
||||||
</InvControl>
|
</InvControl>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user