fix(ui): add initial image dimensions to state

We need to access the initial image dimensions during the creation of the `ImageToImage` graph to determine if we need to resize the image.

Because the `initialImage` is now just an image name, we need to either store (easy) or dynamically retrieve its dimensions during graph creation (a bit less easy).

Took the easiest path. May need to revise this in the future.
This commit is contained in:
psychedelicious
2023-06-21 14:24:30 +10:00
parent 8d3bec57d5
commit 3e0ee838cf
7 changed files with 23 additions and 17 deletions

View File

@ -34,14 +34,14 @@ const InitialImagePreview = () => {
isLoading,
isError,
isSuccess,
} = useGetImageDTOQuery(initialImage ?? skipToken);
} = useGetImageDTOQuery(initialImage?.imageName ?? skipToken);
const handleDrop = useCallback(
({ image_name }: ImageDTO) => {
if (image_name === initialImage) {
(droppedImage: ImageDTO) => {
if (droppedImage.image_name === initialImage?.imageName) {
return;
}
dispatch(initialImageChanged(image_name));
dispatch(initialImageChanged(droppedImage));
},
[dispatch, initialImage]
);

View File

@ -24,7 +24,7 @@ export interface GenerationState {
height: HeightParam;
img2imgStrength: StrengthParam;
infillMethod: string;
initialImage?: string;
initialImage?: { imageName: string; width: number; height: number };
iterations: number;
perlin: number;
positivePrompt: PositivePromptParam;
@ -211,8 +211,9 @@ export const generationSlice = createSlice({
setShouldUseNoiseSettings: (state, action: PayloadAction<boolean>) => {
state.shouldUseNoiseSettings = action.payload;
},
initialImageChanged: (state, action: PayloadAction<string>) => {
state.initialImage = action.payload;
initialImageChanged: (state, action: PayloadAction<ImageDTO>) => {
const { image_name, width, height } = action.payload;
state.initialImage = { imageName: image_name, width, height };
},
modelSelected: (state, action: PayloadAction<string>) => {
state.model = action.payload;