feat(ui): expand config options (#3393)

now may disable individual SD features eg Noise, Variation, etc - stuff
which is not ready for consumption in commercial.
This commit is contained in:
blessedcoolant 2023-05-12 16:10:17 +12:00 committed by GitHub
commit 5013a4b9f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 86 additions and 21 deletions

View File

@ -326,11 +326,11 @@ export type AppFeature =
/** /**
* A disable-able Stable Diffusion feature * A disable-able Stable Diffusion feature
*/ */
export type StableDiffusionFeature = export type SDFeature =
| 'noiseConfig' | 'noise'
| 'variations' | 'variation'
| 'symmetry' | 'symmetry'
| 'tiling' | 'seamless'
| 'hires'; | 'hires';
/** /**
@ -348,6 +348,7 @@ export type AppConfig = {
shouldFetchImages: boolean; shouldFetchImages: boolean;
disabledTabs: InvokeTabName[]; disabledTabs: InvokeTabName[];
disabledFeatures: AppFeature[]; disabledFeatures: AppFeature[];
disabledSDFeatures: SDFeature[];
canRestoreDeletedImagesFromBin: boolean; canRestoreDeletedImagesFromBin: boolean;
sd: { sd: {
iterations: { iterations: {

View File

@ -152,6 +152,7 @@ const CurrentImageButtons = (props: CurrentImageButtonsProps) => {
} = useAppSelector(currentImageButtonsSelector); } = useAppSelector(currentImageButtonsSelector);
const isLightboxEnabled = useFeatureStatus('lightbox').isFeatureEnabled; const isLightboxEnabled = useFeatureStatus('lightbox').isFeatureEnabled;
const isCanvasEnabled = useFeatureStatus('unifiedCanvas').isFeatureEnabled;
const isUpscalingEnabled = useFeatureStatus('upscaling').isFeatureEnabled; const isUpscalingEnabled = useFeatureStatus('upscaling').isFeatureEnabled;
const isFaceRestoreEnabled = useFeatureStatus('faceRestore').isFeatureEnabled; const isFaceRestoreEnabled = useFeatureStatus('faceRestore').isFeatureEnabled;
@ -429,13 +430,15 @@ const CurrentImageButtons = (props: CurrentImageButtonsProps) => {
> >
{t('parameters.sendToImg2Img')} {t('parameters.sendToImg2Img')}
</IAIButton> </IAIButton>
<IAIButton {isCanvasEnabled && (
size="sm" <IAIButton
onClick={handleSendToCanvas} size="sm"
leftIcon={<FaShare />} onClick={handleSendToCanvas}
> leftIcon={<FaShare />}
{t('parameters.sendToUnifiedCanvas')} >
</IAIButton> {t('parameters.sendToUnifiedCanvas')}
</IAIButton>
)}
{/* <IAIButton {/* <IAIButton
size="sm" size="sm"

View File

@ -104,7 +104,10 @@ const HoverableImage = memo((props: HoverableImageProps) => {
const toast = useToast(); const toast = useToast();
const { t } = useTranslation(); const { t } = useTranslation();
const { isFeatureEnabled: isLightboxEnabled } = useFeatureStatus('lightbox');
const isLightboxEnabled = useFeatureStatus('lightbox').isFeatureEnabled;
const isCanvasEnabled = useFeatureStatus('unifiedCanvas').isFeatureEnabled;
const { recallSeed, recallPrompt, recallInitialImage, recallAllParameters } = const { recallSeed, recallPrompt, recallInitialImage, recallAllParameters } =
useParameters(); useParameters();
@ -250,9 +253,11 @@ const HoverableImage = memo((props: HoverableImageProps) => {
> >
{t('parameters.sendToImg2Img')} {t('parameters.sendToImg2Img')}
</MenuItem> </MenuItem>
<MenuItem icon={<FaShare />} onClickCapture={handleSendToCanvas}> {isCanvasEnabled && (
{t('parameters.sendToUnifiedCanvas')} <MenuItem icon={<FaShare />} onClickCapture={handleSendToCanvas}>
</MenuItem> {t('parameters.sendToUnifiedCanvas')}
</MenuItem>
)}
<MenuItem icon={<FaTrash />} onClickCapture={onDeleteDialogOpen}> <MenuItem icon={<FaTrash />} onClickCapture={onDeleteDialogOpen}>
{t('gallery.deleteImage')} {t('gallery.deleteImage')}
</MenuItem> </MenuItem>

View File

@ -6,6 +6,7 @@ import IAICollapse from 'common/components/IAICollapse';
import { memo } from 'react'; import { memo } from 'react';
import { ParamHiresStrength } from './ParamHiresStrength'; import { ParamHiresStrength } from './ParamHiresStrength';
import { setHiresFix } from 'features/parameters/store/postprocessingSlice'; import { setHiresFix } from 'features/parameters/store/postprocessingSlice';
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
const ParamHiresCollapse = () => { const ParamHiresCollapse = () => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -13,10 +14,16 @@ const ParamHiresCollapse = () => {
(state: RootState) => state.postprocessing.hiresFix (state: RootState) => state.postprocessing.hiresFix
); );
const isHiresEnabled = useFeatureStatus('hires').isFeatureEnabled;
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const handleToggle = () => dispatch(setHiresFix(!hiresFix)); const handleToggle = () => dispatch(setHiresFix(!hiresFix));
if (!isHiresEnabled) {
return null;
}
return ( return (
<IAICollapse <IAICollapse
label={t('parameters.hiresOptim')} label={t('parameters.hiresOptim')}

View File

@ -7,9 +7,13 @@ import { RootState } from 'app/store/store';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { setShouldUseNoiseSettings } from 'features/parameters/store/generationSlice'; import { setShouldUseNoiseSettings } from 'features/parameters/store/generationSlice';
import { memo } from 'react'; import { memo } from 'react';
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
const ParamNoiseCollapse = () => { const ParamNoiseCollapse = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const isNoiseEnabled = useFeatureStatus('noise').isFeatureEnabled;
const shouldUseNoiseSettings = useAppSelector( const shouldUseNoiseSettings = useAppSelector(
(state: RootState) => state.generation.shouldUseNoiseSettings (state: RootState) => state.generation.shouldUseNoiseSettings
); );
@ -19,6 +23,10 @@ const ParamNoiseCollapse = () => {
const handleToggle = () => const handleToggle = () =>
dispatch(setShouldUseNoiseSettings(!shouldUseNoiseSettings)); dispatch(setShouldUseNoiseSettings(!shouldUseNoiseSettings));
if (!isNoiseEnabled) {
return null;
}
return ( return (
<IAICollapse <IAICollapse
label={t('parameters.noiseSettings')} label={t('parameters.noiseSettings')}

View File

@ -9,6 +9,7 @@ import { generationSelector } from 'features/parameters/store/generationSelector
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions'; import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
import ParamSeamlessXAxis from './ParamSeamlessXAxis'; import ParamSeamlessXAxis from './ParamSeamlessXAxis';
import ParamSeamlessYAxis from './ParamSeamlessYAxis'; import ParamSeamlessYAxis from './ParamSeamlessYAxis';
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
const selector = createSelector( const selector = createSelector(
generationSelector, generationSelector,
@ -24,10 +25,16 @@ const ParamSeamlessCollapse = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const { shouldUseSeamless } = useAppSelector(selector); const { shouldUseSeamless } = useAppSelector(selector);
const isSeamlessEnabled = useFeatureStatus('seamless').isFeatureEnabled;
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const handleToggle = () => dispatch(setSeamless(!shouldUseSeamless)); const handleToggle = () => dispatch(setSeamless(!shouldUseSeamless));
if (!isSeamlessEnabled) {
return null;
}
return ( return (
<IAICollapse <IAICollapse
label={t('parameters.seamlessTiling')} label={t('parameters.seamlessTiling')}

View File

@ -8,6 +8,7 @@ import IAICollapse from 'common/components/IAICollapse';
import { RootState } from 'app/store/store'; import { RootState } from 'app/store/store';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { setShouldUseSymmetry } from 'features/parameters/store/generationSlice'; import { setShouldUseSymmetry } from 'features/parameters/store/generationSlice';
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
const ParamSymmetryCollapse = () => { const ParamSymmetryCollapse = () => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -15,10 +16,16 @@ const ParamSymmetryCollapse = () => {
(state: RootState) => state.generation.shouldUseSymmetry (state: RootState) => state.generation.shouldUseSymmetry
); );
const isSymmetryEnabled = useFeatureStatus('symmetry').isFeatureEnabled;
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const handleToggle = () => dispatch(setShouldUseSymmetry(!shouldUseSymmetry)); const handleToggle = () => dispatch(setShouldUseSymmetry(!shouldUseSymmetry));
if (!isSymmetryEnabled) {
return null;
}
return ( return (
<IAICollapse <IAICollapse
label={t('parameters.symmetry')} label={t('parameters.symmetry')}

View File

@ -7,6 +7,7 @@ import { setShouldGenerateVariations } from 'features/parameters/store/generatio
import { Flex } from '@chakra-ui/react'; import { Flex } from '@chakra-ui/react';
import IAICollapse from 'common/components/IAICollapse'; import IAICollapse from 'common/components/IAICollapse';
import { memo } from 'react'; import { memo } from 'react';
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
const ParamVariationCollapse = () => { const ParamVariationCollapse = () => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -14,11 +15,17 @@ const ParamVariationCollapse = () => {
(state: RootState) => state.generation.shouldGenerateVariations (state: RootState) => state.generation.shouldGenerateVariations
); );
const isVariationEnabled = useFeatureStatus('variation').isFeatureEnabled;
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const handleToggle = () => const handleToggle = () =>
dispatch(setShouldGenerateVariations(!shouldGenerateVariations)); dispatch(setShouldGenerateVariations(!shouldGenerateVariations));
if (!isVariationEnabled) {
return null;
}
return ( return (
<IAICollapse <IAICollapse
label={t('parameters.variations')} label={t('parameters.variations')}

View File

@ -1,21 +1,40 @@
import { AppFeature } from 'app/types/invokeai'; import { AppFeature, SDFeature } from 'app/types/invokeai';
import { RootState } from 'app/store/store'; import { RootState } from 'app/store/store';
import { useAppSelector } from 'app/store/storeHooks'; import { useAppSelector } from 'app/store/storeHooks';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { InvokeTabName } from 'features/ui/store/tabMap';
export const useFeatureStatus = (
feature: AppFeature | SDFeature | InvokeTabName
) => {
const disabledTabs = useAppSelector(
(state: RootState) => state.config.disabledTabs
);
export const useFeatureStatus = (feature: AppFeature) => {
const disabledFeatures = useAppSelector( const disabledFeatures = useAppSelector(
(state: RootState) => state.config.disabledFeatures (state: RootState) => state.config.disabledFeatures
); );
const disabledSDFeatures = useAppSelector(
(state: RootState) => state.config.disabledSDFeatures
);
const isFeatureDisabled = useMemo( const isFeatureDisabled = useMemo(
() => disabledFeatures.includes(feature), () =>
[disabledFeatures, feature] disabledFeatures.includes(feature as AppFeature) ||
disabledSDFeatures.includes(feature as SDFeature) ||
disabledTabs.includes(feature as InvokeTabName),
[disabledFeatures, disabledSDFeatures, disabledTabs, feature]
); );
const isFeatureEnabled = useMemo( const isFeatureEnabled = useMemo(
() => !disabledFeatures.includes(feature), () =>
[disabledFeatures, feature] !(
disabledFeatures.includes(feature as AppFeature) ||
disabledSDFeatures.includes(feature as SDFeature) ||
disabledTabs.includes(feature as InvokeTabName)
),
[disabledFeatures, disabledSDFeatures, disabledTabs, feature]
); );
return { isFeatureDisabled, isFeatureEnabled }; return { isFeatureDisabled, isFeatureEnabled };

View File

@ -8,6 +8,7 @@ export const initialConfigState: AppConfig = {
shouldFetchImages: false, shouldFetchImages: false,
disabledTabs: [], disabledTabs: [],
disabledFeatures: [], disabledFeatures: [],
disabledSDFeatures: [],
canRestoreDeletedImagesFromBin: true, canRestoreDeletedImagesFromBin: true,
sd: { sd: {
iterations: { iterations: {