mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): update handling of inProgess, do not allow cnet process when processing
This commit is contained in:
parent
2eb367969c
commit
3d99d7ae8b
@ -1,12 +1,12 @@
|
|||||||
import { createSelector } from '@reduxjs/toolkit';
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
|
import { useAppSelector } from 'app/store/storeHooks';
|
||||||
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
||||||
import { validateSeedWeights } from 'common/util/seedWeightPairs';
|
import { validateSeedWeights } from 'common/util/seedWeightPairs';
|
||||||
import { generationSelector } from 'features/parameters/store/generationSelectors';
|
import { generationSelector } from 'features/parameters/store/generationSelectors';
|
||||||
import { systemSelector } from 'features/system/store/systemSelectors';
|
import { systemSelector } from 'features/system/store/systemSelectors';
|
||||||
import { activeTabNameSelector } from 'features/ui/store/uiSelectors';
|
import { activeTabNameSelector } from 'features/ui/store/uiSelectors';
|
||||||
import { isEqual } from 'lodash-es';
|
|
||||||
|
|
||||||
export const readinessSelector = createSelector(
|
const readinessSelector = createSelector(
|
||||||
[generationSelector, systemSelector, activeTabNameSelector],
|
[generationSelector, systemSelector, activeTabNameSelector],
|
||||||
(generation, system, activeTabName) => {
|
(generation, system, activeTabName) => {
|
||||||
const {
|
const {
|
||||||
@ -60,3 +60,8 @@ export const readinessSelector = createSelector(
|
|||||||
},
|
},
|
||||||
defaultSelectorOptions
|
defaultSelectorOptions
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const useIsReadyToInvoke = () => {
|
||||||
|
const { isReady } = useAppSelector(readinessSelector);
|
||||||
|
return isReady;
|
||||||
|
};
|
@ -1,7 +1,5 @@
|
|||||||
import { memo, useCallback } from 'react';
|
import { memo, useCallback } from 'react';
|
||||||
import { RequiredControlNetProcessorNode } from '../store/types';
|
|
||||||
import { ImageDTO } from 'services/api';
|
import { ImageDTO } from 'services/api';
|
||||||
import CannyProcessor from './processors/CannyProcessor';
|
|
||||||
import {
|
import {
|
||||||
ControlNet,
|
ControlNet,
|
||||||
controlNetImageChanged,
|
controlNetImageChanged,
|
||||||
@ -23,11 +21,11 @@ import {
|
|||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import IAISelectableImage from './parameters/IAISelectableImage';
|
import IAISelectableImage from './parameters/IAISelectableImage';
|
||||||
import IAIButton from 'common/components/IAIButton';
|
import IAIButton from 'common/components/IAIButton';
|
||||||
import { controlNetImageProcessed } from '../store/actions';
|
|
||||||
import { FaUndo } from 'react-icons/fa';
|
import { FaUndo } from 'react-icons/fa';
|
||||||
import HedProcessor from './processors/HedProcessor';
|
|
||||||
import ParamControlNetProcessorSelect from './parameters/ParamControlNetProcessorSelect';
|
import ParamControlNetProcessorSelect from './parameters/ParamControlNetProcessorSelect';
|
||||||
import ProcessorComponent from './ProcessorComponent';
|
import ControlNetProcessorComponent from './ControlNetProcessorComponent';
|
||||||
|
import { useIsApplicationReady } from 'features/system/hooks/useIsApplicationReady';
|
||||||
|
import ControlNetPreprocessButton from './ControlNetPreprocessButton';
|
||||||
|
|
||||||
type ControlNetProps = {
|
type ControlNetProps = {
|
||||||
controlNet: ControlNet;
|
controlNet: ControlNet;
|
||||||
@ -47,6 +45,7 @@ const ControlNet = (props: ControlNetProps) => {
|
|||||||
processorNode,
|
processorNode,
|
||||||
} = props.controlNet;
|
} = props.controlNet;
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
const isReady = useIsApplicationReady();
|
||||||
|
|
||||||
const handleControlImageChanged = useCallback(
|
const handleControlImageChanged = useCallback(
|
||||||
(controlImage: ImageDTO) => {
|
(controlImage: ImageDTO) => {
|
||||||
@ -55,14 +54,6 @@ const ControlNet = (props: ControlNetProps) => {
|
|||||||
[controlNetId, dispatch]
|
[controlNetId, dispatch]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleProcess = useCallback(() => {
|
|
||||||
dispatch(
|
|
||||||
controlNetImageProcessed({
|
|
||||||
controlNetId,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}, [controlNetId, dispatch]);
|
|
||||||
|
|
||||||
const handleReset = useCallback(() => {
|
const handleReset = useCallback(() => {
|
||||||
dispatch(
|
dispatch(
|
||||||
controlNetProcessedImageChanged({
|
controlNetProcessedImageChanged({
|
||||||
@ -128,17 +119,11 @@ const ControlNet = (props: ControlNetProps) => {
|
|||||||
controlNetId={controlNetId}
|
controlNetId={controlNetId}
|
||||||
processorNode={processorNode}
|
processorNode={processorNode}
|
||||||
/>
|
/>
|
||||||
<ProcessorComponent
|
<ControlNetProcessorComponent
|
||||||
controlNetId={controlNetId}
|
controlNetId={controlNetId}
|
||||||
processorNode={processorNode}
|
processorNode={processorNode}
|
||||||
/>
|
/>
|
||||||
<IAIButton
|
<ControlNetPreprocessButton controlNet={props.controlNet} />
|
||||||
size="sm"
|
|
||||||
onClick={handleProcess}
|
|
||||||
isDisabled={Boolean(!controlImage)}
|
|
||||||
>
|
|
||||||
Preprocess
|
|
||||||
</IAIButton>
|
|
||||||
<IAIButton
|
<IAIButton
|
||||||
size="sm"
|
size="sm"
|
||||||
leftIcon={<FaUndo />}
|
leftIcon={<FaUndo />}
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
import IAIButton from 'common/components/IAIButton';
|
||||||
|
import { memo, useCallback } from 'react';
|
||||||
|
import { ControlNet } from '../store/controlNetSlice';
|
||||||
|
import { useAppDispatch } from 'app/store/storeHooks';
|
||||||
|
import { controlNetImageProcessed } from '../store/actions';
|
||||||
|
import { useIsReadyToInvoke } from 'common/hooks/useIsReadyToInvoke';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
controlNet: ControlNet;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ControlNetPreprocessButton = (props: Props) => {
|
||||||
|
const { controlNetId, controlImage } = props.controlNet;
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const isReady = useIsReadyToInvoke();
|
||||||
|
|
||||||
|
const handleProcess = useCallback(() => {
|
||||||
|
dispatch(
|
||||||
|
controlNetImageProcessed({
|
||||||
|
controlNetId,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}, [controlNetId, dispatch]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<IAIButton
|
||||||
|
size="sm"
|
||||||
|
onClick={handleProcess}
|
||||||
|
isDisabled={Boolean(!controlImage) || !isReady}
|
||||||
|
>
|
||||||
|
Preprocess
|
||||||
|
</IAIButton>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default memo(ControlNetPreprocessButton);
|
@ -18,7 +18,7 @@ export type ControlNetProcessorProps = {
|
|||||||
processorNode: RequiredControlNetProcessorNode;
|
processorNode: RequiredControlNetProcessorNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ProcessorComponent = (props: ControlNetProcessorProps) => {
|
const ControlNetProcessorComponent = (props: ControlNetProcessorProps) => {
|
||||||
const { controlNetId, processorNode } = props;
|
const { controlNetId, processorNode } = props;
|
||||||
if (processorNode.type === 'canny_image_processor') {
|
if (processorNode.type === 'canny_image_processor') {
|
||||||
return (
|
return (
|
||||||
@ -128,4 +128,4 @@ const ProcessorComponent = (props: ControlNetProcessorProps) => {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default memo(ProcessorComponent);
|
export default memo(ControlNetProcessorComponent);
|
@ -1,28 +0,0 @@
|
|||||||
import { Flex } from '@chakra-ui/react';
|
|
||||||
import { memo } from 'react';
|
|
||||||
import { FaUndo } from 'react-icons/fa';
|
|
||||||
import IAIButton from 'common/components/IAIButton';
|
|
||||||
|
|
||||||
type ControlNetProcessorButtonsProps = {
|
|
||||||
handleProcess: () => void;
|
|
||||||
isProcessDisabled: boolean;
|
|
||||||
handleReset: () => void;
|
|
||||||
isResetDisabled: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
const ControlNetProcessorButtons = (props: ControlNetProcessorButtonsProps) => {
|
|
||||||
const { handleProcess, isProcessDisabled, handleReset, isResetDisabled } =
|
|
||||||
props;
|
|
||||||
return (
|
|
||||||
<Flex
|
|
||||||
sx={{
|
|
||||||
gap: 4,
|
|
||||||
w: 'full',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'stretch',
|
|
||||||
}}
|
|
||||||
></Flex>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default memo(ControlNetProcessorButtons);
|
|
@ -4,7 +4,6 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
|||||||
import { ChangeEvent, KeyboardEvent, useCallback, useRef } from 'react';
|
import { ChangeEvent, KeyboardEvent, useCallback, useRef } from 'react';
|
||||||
|
|
||||||
import { createSelector } from '@reduxjs/toolkit';
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
import { readinessSelector } from 'app/selectors/readinessSelector';
|
|
||||||
import {
|
import {
|
||||||
GenerationState,
|
GenerationState,
|
||||||
clampSymmetrySteps,
|
clampSymmetrySteps,
|
||||||
@ -17,6 +16,7 @@ import { useHotkeys } from 'react-hotkeys-hook';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { userInvoked } from 'app/store/actions';
|
import { userInvoked } from 'app/store/actions';
|
||||||
import IAITextarea from 'common/components/IAITextarea';
|
import IAITextarea from 'common/components/IAITextarea';
|
||||||
|
import { useIsReadyToInvoke } from 'common/hooks/useIsReadyToInvoke';
|
||||||
|
|
||||||
const promptInputSelector = createSelector(
|
const promptInputSelector = createSelector(
|
||||||
[(state: RootState) => state.generation, activeTabNameSelector],
|
[(state: RootState) => state.generation, activeTabNameSelector],
|
||||||
@ -39,7 +39,7 @@ const promptInputSelector = createSelector(
|
|||||||
const ParamPositiveConditioning = () => {
|
const ParamPositiveConditioning = () => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { prompt, activeTabName } = useAppSelector(promptInputSelector);
|
const { prompt, activeTabName } = useAppSelector(promptInputSelector);
|
||||||
const { isReady } = useAppSelector(readinessSelector);
|
const isReady = useIsReadyToInvoke();
|
||||||
|
|
||||||
const promptRef = useRef<HTMLTextAreaElement>(null);
|
const promptRef = useRef<HTMLTextAreaElement>(null);
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { Box } from '@chakra-ui/react';
|
import { Box } from '@chakra-ui/react';
|
||||||
import { readinessSelector } from 'app/selectors/readinessSelector';
|
|
||||||
import { userInvoked } from 'app/store/actions';
|
import { userInvoked } from 'app/store/actions';
|
||||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
import IAIButton, { IAIButtonProps } from 'common/components/IAIButton';
|
import IAIButton, { IAIButtonProps } from 'common/components/IAIButton';
|
||||||
import IAIIconButton, {
|
import IAIIconButton, {
|
||||||
IAIIconButtonProps,
|
IAIIconButtonProps,
|
||||||
} from 'common/components/IAIIconButton';
|
} from 'common/components/IAIIconButton';
|
||||||
|
import { useIsReadyToInvoke } from 'common/hooks/useIsReadyToInvoke';
|
||||||
import { clampSymmetrySteps } from 'features/parameters/store/generationSlice';
|
import { clampSymmetrySteps } from 'features/parameters/store/generationSlice';
|
||||||
import ProgressBar from 'features/system/components/ProgressBar';
|
import ProgressBar from 'features/system/components/ProgressBar';
|
||||||
import { activeTabNameSelector } from 'features/ui/store/uiSelectors';
|
import { activeTabNameSelector } from 'features/ui/store/uiSelectors';
|
||||||
@ -22,7 +22,7 @@ interface InvokeButton
|
|||||||
export default function InvokeButton(props: InvokeButton) {
|
export default function InvokeButton(props: InvokeButton) {
|
||||||
const { iconButton = false, ...rest } = props;
|
const { iconButton = false, ...rest } = props;
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { isReady } = useAppSelector(readinessSelector);
|
const isReady = useIsReadyToInvoke();
|
||||||
const activeTabName = useAppSelector(activeTabNameSelector);
|
const activeTabName = useAppSelector(activeTabNameSelector);
|
||||||
|
|
||||||
const handleInvoke = useCallback(() => {
|
const handleInvoke = useCallback(() => {
|
||||||
|
@ -19,6 +19,9 @@ const isApplicationReadySelector = createSelector(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the application is ready to be used, i.e. if the initial startup process is finished.
|
||||||
|
*/
|
||||||
export const useIsApplicationReady = () => {
|
export const useIsApplicationReady = () => {
|
||||||
const { disabledTabs, wereModelsReceived, wasSchemaParsed } = useAppSelector(
|
const { disabledTabs, wereModelsReceived, wasSchemaParsed } = useAppSelector(
|
||||||
isApplicationReadySelector
|
isApplicationReadySelector
|
||||||
|
Loading…
x
Reference in New Issue
Block a user