mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): support disabling controlnet models & processors
This commit is contained in:
parent
a3fa38b353
commit
e00fed5c46
@ -117,6 +117,8 @@ export type AppConfig = {
|
|||||||
canRestoreDeletedImagesFromBin: boolean;
|
canRestoreDeletedImagesFromBin: boolean;
|
||||||
sd: {
|
sd: {
|
||||||
defaultModel?: string;
|
defaultModel?: string;
|
||||||
|
disabledControlNetModels: string[];
|
||||||
|
disabledControlNetProcessors: string[];
|
||||||
iterations: {
|
iterations: {
|
||||||
initial: number;
|
initial: number;
|
||||||
min: number;
|
min: number;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { useAppDispatch } from 'app/store/storeHooks';
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
import IAICustomSelect, {
|
import IAICustomSelect, {
|
||||||
IAICustomSelectOption,
|
IAICustomSelectOption,
|
||||||
} from 'common/components/IAICustomSelect';
|
} from 'common/components/IAICustomSelect';
|
||||||
@ -9,6 +10,7 @@ import {
|
|||||||
ControlNetModelName,
|
ControlNetModelName,
|
||||||
} from 'features/controlNet/store/constants';
|
} from 'features/controlNet/store/constants';
|
||||||
import { controlNetModelChanged } from 'features/controlNet/store/controlNetSlice';
|
import { controlNetModelChanged } from 'features/controlNet/store/controlNetSlice';
|
||||||
|
import { configSelector } from 'features/system/store/configSelectors';
|
||||||
import { map } from 'lodash-es';
|
import { map } from 'lodash-es';
|
||||||
import { ChangeEvent, memo, useCallback } from 'react';
|
import { ChangeEvent, memo, useCallback } from 'react';
|
||||||
|
|
||||||
@ -17,10 +19,12 @@ type ParamControlNetModelProps = {
|
|||||||
model: ControlNetModelName;
|
model: ControlNetModelName;
|
||||||
};
|
};
|
||||||
|
|
||||||
const DATA = map(CONTROLNET_MODELS, (m) => ({
|
const selector = createSelector(configSelector, (config) => {
|
||||||
key: m.label,
|
return map(CONTROLNET_MODELS, (m) => ({
|
||||||
value: m.type,
|
key: m.label,
|
||||||
}));
|
value: m.type,
|
||||||
|
})).filter((d) => !config.sd.disabledControlNetModels.includes(d.value));
|
||||||
|
});
|
||||||
|
|
||||||
// const DATA: IAICustomSelectOption[] = map(CONTROLNET_MODELS, (m) => ({
|
// const DATA: IAICustomSelectOption[] = map(CONTROLNET_MODELS, (m) => ({
|
||||||
// value: m.type,
|
// value: m.type,
|
||||||
@ -30,6 +34,7 @@ const DATA = map(CONTROLNET_MODELS, (m) => ({
|
|||||||
|
|
||||||
const ParamControlNetModel = (props: ParamControlNetModelProps) => {
|
const ParamControlNetModel = (props: ParamControlNetModelProps) => {
|
||||||
const { controlNetId, model } = props;
|
const { controlNetId, model } = props;
|
||||||
|
const controlNetModels = useAppSelector(selector);
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const isReady = useIsReadyToInvoke();
|
const isReady = useIsReadyToInvoke();
|
||||||
|
|
||||||
@ -55,7 +60,7 @@ const ParamControlNetModel = (props: ParamControlNetModelProps) => {
|
|||||||
<IAISelect
|
<IAISelect
|
||||||
tooltip={model}
|
tooltip={model}
|
||||||
tooltipProps={{ placement: 'top', hasArrow: true }}
|
tooltipProps={{ placement: 'top', hasArrow: true }}
|
||||||
validValues={DATA}
|
validValues={controlNetModels}
|
||||||
value={model}
|
value={model}
|
||||||
onChange={handleModelChanged}
|
onChange={handleModelChanged}
|
||||||
isDisabled={!isReady}
|
isDisabled={!isReady}
|
||||||
|
@ -7,11 +7,13 @@ import {
|
|||||||
ControlNetProcessorType,
|
ControlNetProcessorType,
|
||||||
} from '../../store/types';
|
} from '../../store/types';
|
||||||
import { controlNetProcessorTypeChanged } from '../../store/controlNetSlice';
|
import { controlNetProcessorTypeChanged } from '../../store/controlNetSlice';
|
||||||
import { useAppDispatch } from 'app/store/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
import { CONTROLNET_PROCESSORS } from '../../store/constants';
|
import { CONTROLNET_PROCESSORS } from '../../store/constants';
|
||||||
import { map } from 'lodash-es';
|
import { map } from 'lodash-es';
|
||||||
import { useIsReadyToInvoke } from 'common/hooks/useIsReadyToInvoke';
|
import { useIsReadyToInvoke } from 'common/hooks/useIsReadyToInvoke';
|
||||||
import IAISelect from 'common/components/IAISelect';
|
import IAISelect from 'common/components/IAISelect';
|
||||||
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
|
import { configSelector } from 'features/system/store/configSelectors';
|
||||||
|
|
||||||
type ParamControlNetProcessorSelectProps = {
|
type ParamControlNetProcessorSelectProps = {
|
||||||
controlNetId: string;
|
controlNetId: string;
|
||||||
@ -26,6 +28,22 @@ const CONTROLNET_PROCESSOR_TYPES = map(CONTROLNET_PROCESSORS, (p) => ({
|
|||||||
a.value === 'none' ? -1 : b.value === 'none' ? 1 : a.key.localeCompare(b.key)
|
a.value === 'none' ? -1 : b.value === 'none' ? 1 : a.key.localeCompare(b.key)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const selector = createSelector(configSelector, (config) => {
|
||||||
|
return map(CONTROLNET_PROCESSORS, (p) => ({
|
||||||
|
value: p.type,
|
||||||
|
key: p.label,
|
||||||
|
}))
|
||||||
|
.sort((a, b) =>
|
||||||
|
// sort 'none' to the top
|
||||||
|
a.value === 'none'
|
||||||
|
? -1
|
||||||
|
: b.value === 'none'
|
||||||
|
? 1
|
||||||
|
: a.key.localeCompare(b.key)
|
||||||
|
)
|
||||||
|
.filter((d) => !config.sd.disabledControlNetProcessors.includes(d.value));
|
||||||
|
});
|
||||||
|
|
||||||
// const CONTROLNET_PROCESSOR_TYPES: IAICustomSelectOption[] = map(
|
// const CONTROLNET_PROCESSOR_TYPES: IAICustomSelectOption[] = map(
|
||||||
// CONTROLNET_PROCESSORS,
|
// CONTROLNET_PROCESSORS,
|
||||||
// (p) => ({
|
// (p) => ({
|
||||||
@ -48,6 +66,7 @@ const ParamControlNetProcessorSelect = (
|
|||||||
const { controlNetId, processorNode } = props;
|
const { controlNetId, processorNode } = props;
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const isReady = useIsReadyToInvoke();
|
const isReady = useIsReadyToInvoke();
|
||||||
|
const controlNetProcessors = useAppSelector(selector);
|
||||||
|
|
||||||
const handleProcessorTypeChanged = useCallback(
|
const handleProcessorTypeChanged = useCallback(
|
||||||
(e: ChangeEvent<HTMLSelectElement>) => {
|
(e: ChangeEvent<HTMLSelectElement>) => {
|
||||||
@ -76,8 +95,9 @@ const ParamControlNetProcessorSelect = (
|
|||||||
<IAISelect
|
<IAISelect
|
||||||
label="Processor"
|
label="Processor"
|
||||||
value={processorNode.type ?? 'canny_image_processor'}
|
value={processorNode.type ?? 'canny_image_processor'}
|
||||||
validValues={CONTROLNET_PROCESSOR_TYPES}
|
validValues={controlNetProcessors}
|
||||||
onChange={handleProcessorTypeChanged}
|
onChange={handleProcessorTypeChanged}
|
||||||
|
isDisabled={!isReady}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
// return (
|
// return (
|
||||||
|
@ -10,6 +10,8 @@ export const initialConfigState: AppConfig = {
|
|||||||
disabledSDFeatures: [],
|
disabledSDFeatures: [],
|
||||||
canRestoreDeletedImagesFromBin: true,
|
canRestoreDeletedImagesFromBin: true,
|
||||||
sd: {
|
sd: {
|
||||||
|
disabledControlNetModels: [],
|
||||||
|
disabledControlNetProcessors: [],
|
||||||
iterations: {
|
iterations: {
|
||||||
initial: 1,
|
initial: 1,
|
||||||
min: 1,
|
min: 1,
|
||||||
|
Loading…
Reference in New Issue
Block a user