add ability to disable lora, ti, dynamic prompts, vae selection

This commit is contained in:
Mary Hipp 2023-07-07 11:13:42 -04:00
parent 2cbe98b1b1
commit 888c47d37b
11 changed files with 74 additions and 41 deletions

View File

@ -93,7 +93,8 @@ export type AppFeature =
| 'discordLink'
| 'bugLink'
| 'localization'
| 'consoleLogging';
| 'consoleLogging'
| 'dynamicPrompting';
/**
* A disable-able Stable Diffusion feature
@ -104,7 +105,10 @@ export type SDFeature =
| 'variation'
| 'symmetry'
| 'seamless'
| 'hires';
| 'hires'
| 'lora'
| 'tiEmbedding'
| 'vae';
/**
* Configuration options for the InvokeAI UI.

View File

@ -7,6 +7,7 @@ import IAICollapse from 'common/components/IAICollapse';
import ParamDynamicPromptsCombinatorial from './ParamDynamicPromptsCombinatorial';
import ParamDynamicPromptsToggle from './ParamDynamicPromptsEnabled';
import ParamDynamicPromptsMaxPrompts from './ParamDynamicPromptsMaxPrompts';
import { useFeatureStatus } from '../../system/hooks/useFeatureStatus';
const selector = createSelector(
stateSelector,
@ -21,6 +22,13 @@ const selector = createSelector(
const ParamDynamicPromptsCollapse = () => {
const { activeLabel } = useAppSelector(selector);
const isDynamicPromptingEnabled =
useFeatureStatus('dynamicPrompting').isFeatureEnabled;
if (!isDynamicPromptingEnabled) {
return null;
}
return (
<IAICollapse label="Dynamic Prompts" activeLabel={activeLabel}>
<Flex sx={{ gap: 2, flexDir: 'column' }}>

View File

@ -16,15 +16,17 @@ import { forEach } from 'lodash-es';
import { PropsWithChildren, useCallback, useMemo, useRef } from 'react';
import { useGetTextualInversionModelsQuery } from 'services/api/endpoints/models';
import { PARAMETERS_PANEL_WIDTH } from 'theme/util/constants';
import { useFeatureStatus } from '../../system/hooks/useFeatureStatus';
type Props = PropsWithChildren & {
onSelect: (v: string) => void;
isOpen: boolean;
onClose: () => void;
enabled?: boolean;
};
const ParamEmbeddingPopover = (props: Props) => {
const { onSelect, isOpen, onClose, children } = props;
const { onSelect, isOpen, onClose, children, enabled } = props;
const { data: embeddingQueryData } = useGetTextualInversionModelsQuery();
const inputRef = useRef<HTMLInputElement>(null);

View File

@ -8,6 +8,7 @@ import { size } from 'lodash-es';
import { memo } from 'react';
import ParamLoraList from './ParamLoraList';
import ParamLoraSelect from './ParamLoraSelect';
import { useFeatureStatus } from '../../system/hooks/useFeatureStatus';
const selector = createSelector(
stateSelector,
@ -23,6 +24,12 @@ const selector = createSelector(
const ParamLoraCollapse = () => {
const { activeLabel } = useAppSelector(selector);
const isLoraEnabled = useFeatureStatus('lora').isFeatureEnabled;
if (!isLoraEnabled) {
return null;
}
return (
<IAICollapse label={'LoRA'} activeLabel={activeLabel}>
<Flex sx={{ flexDir: 'column', gap: 2 }}>

View File

@ -1,19 +0,0 @@
import { Box, Flex } from '@chakra-ui/react';
import ModelSelect from 'features/system/components/ModelSelect';
import VAESelect from 'features/system/components/VAESelect';
import { memo } from 'react';
const ParamModelandVAE = () => {
return (
<Flex gap={3} w="full">
<Box w="full">
<ModelSelect />
</Box>
<Box w="full">
<VAESelect />
</Box>
</Flex>
);
};
export default memo(ParamModelandVAE);

View File

@ -0,0 +1,31 @@
import { Box, Flex } from '@chakra-ui/react';
import ModelSelect from 'features/system/components/ModelSelect';
import VAESelect from 'features/system/components/VAESelect';
import { memo } from 'react';
import { useFeatureStatus } from '../../../../system/hooks/useFeatureStatus';
import ParamScheduler from './ParamScheduler';
const ParamModelandVAEandScheduler = () => {
const isVaeEnabled = useFeatureStatus('vae').isFeatureEnabled;
return (
<Flex gap={3} w="full" flexWrap={isVaeEnabled ? 'wrap' : 'nowrap'}>
<Flex gap={3} w="full">
<Box w="full">
<ModelSelect />
</Box>
{isVaeEnabled && (
<Box w="full">
<VAESelect />
</Box>
)}
</Flex>
<Box w="full">
<ParamScheduler />
</Box>
</Flex>
);
};
export default memo(ParamModelandVAEandScheduler);

View File

@ -8,6 +8,7 @@ import { setNegativePrompt } from 'features/parameters/store/generationSlice';
import { ChangeEvent, KeyboardEvent, useCallback, useRef } from 'react';
import { flushSync } from 'react-dom';
import { useTranslation } from 'react-i18next';
import { useFeatureStatus } from '../../../../system/hooks/useFeatureStatus';
const ParamNegativeConditioning = () => {
const negativePrompt = useAppSelector(
@ -71,6 +72,8 @@ const ParamNegativeConditioning = () => {
[dispatch, onClose, negativePrompt]
);
const isTiEmbeddingEnabled = useFeatureStatus('tiEmbedding').isFeatureEnabled;
return (
<FormControl>
<ParamEmbeddingPopover
@ -85,13 +88,13 @@ const ParamNegativeConditioning = () => {
value={negativePrompt}
placeholder={t('parameters.negativePromptPlaceholder')}
onChange={handleChangePrompt}
onKeyDown={handleKeyDown}
resize="vertical"
fontSize="sm"
minH={16}
{...(isTiEmbeddingEnabled && { onKeyDown: handleKeyDown })}
/>
</ParamEmbeddingPopover>
{!isOpen && (
{!isOpen && isTiEmbeddingEnabled && (
<Box
sx={{
position: 'absolute',

View File

@ -20,6 +20,7 @@ import { isEqual } from 'lodash-es';
import { flushSync } from 'react-dom';
import { useHotkeys } from 'react-hotkeys-hook';
import { useTranslation } from 'react-i18next';
import { useFeatureStatus } from '../../../../system/hooks/useFeatureStatus';
const promptInputSelector = createSelector(
[(state: RootState) => state.generation, activeTabNameSelector],
@ -114,6 +115,8 @@ const ParamPositiveConditioning = () => {
[isReady, dispatch, activeTabName, onOpen]
);
const isTiEmbeddingEnabled = useFeatureStatus('tiEmbedding').isFeatureEnabled;
// const handleSelect = (e: MouseEvent<HTMLTextAreaElement>) => {
// const target = e.target as HTMLTextAreaElement;
// setCaret({ start: target.selectionStart, end: target.selectionEnd });
@ -134,13 +137,13 @@ const ParamPositiveConditioning = () => {
value={prompt}
placeholder={t('parameters.positivePromptPlaceholder')}
onChange={handleChangePrompt}
onKeyDown={handleKeyDown}
resize="vertical"
minH={32}
{...(isTiEmbeddingEnabled && { onKeyDown: handleKeyDown })}
/>
</ParamEmbeddingPopover>
</FormControl>
{!isOpen && (
{!isOpen && isTiEmbeddingEnabled && (
<Box
sx={{
position: 'absolute',

View File

@ -6,8 +6,7 @@ import IAICollapse from 'common/components/IAICollapse';
import ParamCFGScale from 'features/parameters/components/Parameters/Core/ParamCFGScale';
import ParamHeight from 'features/parameters/components/Parameters/Core/ParamHeight';
import ParamIterations from 'features/parameters/components/Parameters/Core/ParamIterations';
import ParamModelandVAE from 'features/parameters/components/Parameters/Core/ParamModelandVAE';
import ParamScheduler from 'features/parameters/components/Parameters/Core/ParamScheduler';
import ParamModelandVAEandScheduler from 'features/parameters/components/Parameters/Core/ParamModelandVAEandScheduler';
import ParamSteps from 'features/parameters/components/Parameters/Core/ParamSteps';
import ParamWidth from 'features/parameters/components/Parameters/Core/ParamWidth';
import ImageToImageFit from 'features/parameters/components/Parameters/ImageToImage/ImageToImageFit';
@ -48,7 +47,7 @@ const ImageToImageTabCoreParameters = () => {
>
{shouldUseSliders ? (
<>
<ParamModelandVAE />
<ParamModelandVAEandScheduler />
<Box pt={2}>
<ParamSeedFull />
</Box>
@ -65,8 +64,7 @@ const ImageToImageTabCoreParameters = () => {
<ParamSteps />
<ParamCFGScale />
</Flex>
<ParamModelandVAE />
<ParamScheduler />
<ParamModelandVAEandScheduler />
<Box pt={2}>
<ParamSeedFull />
</Box>

View File

@ -7,8 +7,7 @@ import IAICollapse from 'common/components/IAICollapse';
import ParamCFGScale from 'features/parameters/components/Parameters/Core/ParamCFGScale';
import ParamHeight from 'features/parameters/components/Parameters/Core/ParamHeight';
import ParamIterations from 'features/parameters/components/Parameters/Core/ParamIterations';
import ParamModelandVAE from 'features/parameters/components/Parameters/Core/ParamModelandVAE';
import ParamScheduler from 'features/parameters/components/Parameters/Core/ParamScheduler';
import ParamModelandVAEandScheduler from 'features/parameters/components/Parameters/Core/ParamModelandVAEandScheduler';
import ParamSteps from 'features/parameters/components/Parameters/Core/ParamSteps';
import ParamWidth from 'features/parameters/components/Parameters/Core/ParamWidth';
import ParamSeedFull from 'features/parameters/components/Parameters/Seed/ParamSeedFull';
@ -44,7 +43,7 @@ const TextToImageTabCoreParameters = () => {
>
{shouldUseSliders ? (
<>
<ParamModelandVAE />
<ParamModelandVAEandScheduler />
<Box pt={2}>
<ParamSeedFull />
</Box>
@ -61,8 +60,7 @@ const TextToImageTabCoreParameters = () => {
<ParamSteps />
<ParamCFGScale />
</Flex>
<ParamModelandVAE />
<ParamScheduler />
<ParamModelandVAEandScheduler />
<Box pt={2}>
<ParamSeedFull />
</Box>

View File

@ -8,8 +8,7 @@ import ParamBoundingBoxHeight from 'features/parameters/components/Parameters/Ca
import ParamBoundingBoxWidth from 'features/parameters/components/Parameters/Canvas/BoundingBox/ParamBoundingBoxWidth';
import ParamCFGScale from 'features/parameters/components/Parameters/Core/ParamCFGScale';
import ParamIterations from 'features/parameters/components/Parameters/Core/ParamIterations';
import ParamModelandVAE from 'features/parameters/components/Parameters/Core/ParamModelandVAE';
import ParamScheduler from 'features/parameters/components/Parameters/Core/ParamScheduler';
import ParamModelandVAEandScheduler from 'features/parameters/components/Parameters/Core/ParamModelandVAEandScheduler';
import ParamSteps from 'features/parameters/components/Parameters/Core/ParamSteps';
import ImageToImageStrength from 'features/parameters/components/Parameters/ImageToImage/ImageToImageStrength';
import ParamSeedFull from 'features/parameters/components/Parameters/Seed/ParamSeedFull';
@ -45,7 +44,7 @@ const UnifiedCanvasCoreParameters = () => {
>
{shouldUseSliders ? (
<>
<ParamModelandVAE />
<ParamModelandVAEandScheduler />
<Box pt={2}>
<ParamSeedFull />
</Box>
@ -62,8 +61,7 @@ const UnifiedCanvasCoreParameters = () => {
<ParamSteps />
<ParamCFGScale />
</Flex>
<ParamModelandVAE />
<ParamScheduler />
<ParamModelandVAEandScheduler />
<Box pt={2}>
<ParamSeedFull />
</Box>