diff --git a/invokeai/frontend/web/src/features/sdxl/components/SDXLRefiner/ParamSDXLRefinerCFGScale.tsx b/invokeai/frontend/web/src/features/sdxl/components/SDXLRefiner/ParamSDXLRefinerCFGScale.tsx index 9aa657c633..6dcb12e47a 100644 --- a/invokeai/frontend/web/src/features/sdxl/components/SDXLRefiner/ParamSDXLRefinerCFGScale.tsx +++ b/invokeai/frontend/web/src/features/sdxl/components/SDXLRefiner/ParamSDXLRefinerCFGScale.tsx @@ -1,3 +1,5 @@ +import { createMemoizedSelector } from 'app/store/createMemoizedSelector'; +import { stateSelector } from 'app/store/store'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { InvControl } from 'common/components/InvControl/InvControl'; import { InvSlider } from 'common/components/InvSlider/InvSlider'; @@ -5,26 +7,50 @@ import { setRefinerCFGScale } from 'features/sdxl/store/sdxlSlice'; import { memo, useCallback } from 'react'; 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 refinerCFGScale = useAppSelector((state) => state.sdxl.refinerCFGScale); + const { marks, min, inputMax, sliderMax, coarseStep, fineStep, initial } = + useAppSelector(selector); const dispatch = useAppDispatch(); const { t } = useTranslation(); - const handleChange = useCallback( + const onChange = useCallback( (v: number) => dispatch(setRefinerCFGScale(v)), [dispatch] ); + const onReset = useCallback(() => { + dispatch(setRefinerCFGScale(initial)); + }, [dispatch, initial]); + return ( ); diff --git a/invokeai/frontend/web/src/features/sdxl/components/SDXLRefiner/ParamSDXLRefinerSteps.tsx b/invokeai/frontend/web/src/features/sdxl/components/SDXLRefiner/ParamSDXLRefinerSteps.tsx index c7251538de..218ae99560 100644 --- a/invokeai/frontend/web/src/features/sdxl/components/SDXLRefiner/ParamSDXLRefinerSteps.tsx +++ b/invokeai/frontend/web/src/features/sdxl/components/SDXLRefiner/ParamSDXLRefinerSteps.tsx @@ -1,3 +1,5 @@ +import { createMemoizedSelector } from 'app/store/createMemoizedSelector'; +import { stateSelector } from 'app/store/store'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { InvControl } from 'common/components/InvControl/InvControl'; import { InvSlider } from 'common/components/InvSlider/InvSlider'; @@ -5,26 +7,51 @@ import { setRefinerSteps } from 'features/sdxl/store/sdxlSlice'; import { memo, useCallback } from 'react'; 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 { initial, min, sliderMax, inputMax, step, fineStep, marks } = + useAppSelector(selector); const refinerSteps = useAppSelector((state) => state.sdxl.refinerSteps); const dispatch = useAppDispatch(); const { t } = useTranslation(); - const handleChange = useCallback( + + const onChange = useCallback( (v: number) => { dispatch(setRefinerSteps(v)); }, [dispatch] ); + const onReset = useCallback(() => { + dispatch(setRefinerSteps(initial)); + }, [dispatch, initial]); + return ( );