mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): on page load, if CA processed image no longer exists, re-process it
This commit is contained in:
parent
2871676f79
commit
6d067e56f2
@ -22,7 +22,13 @@ import type { BatchConfig } from 'services/api/types';
|
|||||||
import { socketInvocationComplete } from 'services/events/actions';
|
import { socketInvocationComplete } from 'services/events/actions';
|
||||||
import { assert } from 'tsafe';
|
import { assert } from 'tsafe';
|
||||||
|
|
||||||
const matcher = isAnyOf(caLayerImageChanged, caLayerProcessorConfigChanged, caLayerModelChanged, caLayerRecalled);
|
const matcher = isAnyOf(
|
||||||
|
caLayerImageChanged,
|
||||||
|
caLayerProcessedImageChanged,
|
||||||
|
caLayerProcessorConfigChanged,
|
||||||
|
caLayerModelChanged,
|
||||||
|
caLayerRecalled
|
||||||
|
);
|
||||||
|
|
||||||
const DEBOUNCE_MS = 300;
|
const DEBOUNCE_MS = 300;
|
||||||
const log = logger('session');
|
const log = logger('session');
|
||||||
@ -73,9 +79,10 @@ export const addControlAdapterPreprocessor = (startAppListening: AppStartListeni
|
|||||||
const originalConfig = originalLayer?.controlAdapter.processorConfig;
|
const originalConfig = originalLayer?.controlAdapter.processorConfig;
|
||||||
|
|
||||||
const image = layer.controlAdapter.image;
|
const image = layer.controlAdapter.image;
|
||||||
|
const processedImage = layer.controlAdapter.processedImage;
|
||||||
const config = layer.controlAdapter.processorConfig;
|
const config = layer.controlAdapter.processorConfig;
|
||||||
|
|
||||||
if (isEqual(config, originalConfig) && isEqual(image, originalImage)) {
|
if (isEqual(config, originalConfig) && isEqual(image, originalImage) && processedImage) {
|
||||||
// Neither config nor image have changed, we can bail
|
// Neither config nor image have changed, we can bail
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import {
|
|||||||
caLayerControlModeChanged,
|
caLayerControlModeChanged,
|
||||||
caLayerImageChanged,
|
caLayerImageChanged,
|
||||||
caLayerModelChanged,
|
caLayerModelChanged,
|
||||||
|
caLayerProcessedImageChanged,
|
||||||
caLayerProcessorConfigChanged,
|
caLayerProcessorConfigChanged,
|
||||||
caOrIPALayerBeginEndStepPctChanged,
|
caOrIPALayerBeginEndStepPctChanged,
|
||||||
caOrIPALayerWeightChanged,
|
caOrIPALayerWeightChanged,
|
||||||
@ -84,6 +85,14 @@ export const CALayerControlAdapterWrapper = memo(({ layerId }: Props) => {
|
|||||||
[dispatch, layerId]
|
[dispatch, layerId]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const onErrorLoadingImage = useCallback(() => {
|
||||||
|
dispatch(caLayerImageChanged({ layerId, imageDTO: null }));
|
||||||
|
}, [dispatch, layerId]);
|
||||||
|
|
||||||
|
const onErrorLoadingProcessedImage = useCallback(() => {
|
||||||
|
dispatch(caLayerProcessedImageChanged({ layerId, imageDTO: null }));
|
||||||
|
}, [dispatch, layerId]);
|
||||||
|
|
||||||
const droppableData = useMemo<CALayerImageDropData>(
|
const droppableData = useMemo<CALayerImageDropData>(
|
||||||
() => ({
|
() => ({
|
||||||
actionType: 'SET_CA_LAYER_IMAGE',
|
actionType: 'SET_CA_LAYER_IMAGE',
|
||||||
@ -114,6 +123,8 @@ export const CALayerControlAdapterWrapper = memo(({ layerId }: Props) => {
|
|||||||
onChangeImage={onChangeImage}
|
onChangeImage={onChangeImage}
|
||||||
droppableData={droppableData}
|
droppableData={droppableData}
|
||||||
postUploadAction={postUploadAction}
|
postUploadAction={postUploadAction}
|
||||||
|
onErrorLoadingImage={onErrorLoadingImage}
|
||||||
|
onErrorLoadingProcessedImage={onErrorLoadingProcessedImage}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -28,6 +28,8 @@ type Props = {
|
|||||||
onChangeProcessorConfig: (processorConfig: ProcessorConfig | null) => void;
|
onChangeProcessorConfig: (processorConfig: ProcessorConfig | null) => void;
|
||||||
onChangeModel: (modelConfig: ControlNetModelConfig | T2IAdapterModelConfig) => void;
|
onChangeModel: (modelConfig: ControlNetModelConfig | T2IAdapterModelConfig) => void;
|
||||||
onChangeImage: (imageDTO: ImageDTO | null) => void;
|
onChangeImage: (imageDTO: ImageDTO | null) => void;
|
||||||
|
onErrorLoadingImage: () => void;
|
||||||
|
onErrorLoadingProcessedImage: () => void;
|
||||||
droppableData: TypesafeDroppableData;
|
droppableData: TypesafeDroppableData;
|
||||||
postUploadAction: PostUploadAction;
|
postUploadAction: PostUploadAction;
|
||||||
};
|
};
|
||||||
@ -41,6 +43,8 @@ export const ControlAdapter = memo(
|
|||||||
onChangeProcessorConfig,
|
onChangeProcessorConfig,
|
||||||
onChangeModel,
|
onChangeModel,
|
||||||
onChangeImage,
|
onChangeImage,
|
||||||
|
onErrorLoadingImage,
|
||||||
|
onErrorLoadingProcessedImage,
|
||||||
droppableData,
|
droppableData,
|
||||||
postUploadAction,
|
postUploadAction,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
@ -91,6 +95,8 @@ export const ControlAdapter = memo(
|
|||||||
onChangeImage={onChangeImage}
|
onChangeImage={onChangeImage}
|
||||||
droppableData={droppableData}
|
droppableData={droppableData}
|
||||||
postUploadAction={postUploadAction}
|
postUploadAction={postUploadAction}
|
||||||
|
onErrorLoadingImage={onErrorLoadingImage}
|
||||||
|
onErrorLoadingProcessedImage={onErrorLoadingProcessedImage}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@ -27,10 +27,19 @@ type Props = {
|
|||||||
onChangeImage: (imageDTO: ImageDTO | null) => void;
|
onChangeImage: (imageDTO: ImageDTO | null) => void;
|
||||||
droppableData: TypesafeDroppableData;
|
droppableData: TypesafeDroppableData;
|
||||||
postUploadAction: PostUploadAction;
|
postUploadAction: PostUploadAction;
|
||||||
|
onErrorLoadingImage: () => void;
|
||||||
|
onErrorLoadingProcessedImage: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ControlAdapterImagePreview = memo(
|
export const ControlAdapterImagePreview = memo(
|
||||||
({ controlAdapter, onChangeImage, droppableData, postUploadAction }: Props) => {
|
({
|
||||||
|
controlAdapter,
|
||||||
|
onChangeImage,
|
||||||
|
droppableData,
|
||||||
|
postUploadAction,
|
||||||
|
onErrorLoadingImage,
|
||||||
|
onErrorLoadingProcessedImage,
|
||||||
|
}: Props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const autoAddBoardId = useAppSelector((s) => s.gallery.autoAddBoardId);
|
const autoAddBoardId = useAppSelector((s) => s.gallery.autoAddBoardId);
|
||||||
@ -128,10 +137,23 @@ export const ControlAdapterImagePreview = memo(
|
|||||||
controlAdapter.processorConfig !== null;
|
controlAdapter.processorConfig !== null;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isConnected && (isErrorControlImage || isErrorProcessedControlImage)) {
|
if (!isConnected) {
|
||||||
handleResetControlImage();
|
return;
|
||||||
}
|
}
|
||||||
}, [handleResetControlImage, isConnected, isErrorControlImage, isErrorProcessedControlImage]);
|
if (isErrorControlImage) {
|
||||||
|
onErrorLoadingImage();
|
||||||
|
}
|
||||||
|
if (isErrorProcessedControlImage) {
|
||||||
|
onErrorLoadingProcessedImage();
|
||||||
|
}
|
||||||
|
}, [
|
||||||
|
handleResetControlImage,
|
||||||
|
isConnected,
|
||||||
|
isErrorControlImage,
|
||||||
|
isErrorProcessedControlImage,
|
||||||
|
onErrorLoadingImage,
|
||||||
|
onErrorLoadingProcessedImage,
|
||||||
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
@ -167,6 +189,7 @@ export const ControlAdapterImagePreview = memo(
|
|||||||
droppableData={droppableData}
|
droppableData={droppableData}
|
||||||
imageDTO={processedControlImage}
|
imageDTO={processedControlImage}
|
||||||
isUploadDisabled={true}
|
isUploadDisabled={true}
|
||||||
|
onError={handleResetControlImage}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user