Skip to content

Commit 4b85dfc

Browse files
Mary Hipppsychedelicious
authored andcommitted
(ui): restore optioanl limit on upcsale output resolution
1 parent 21deefd commit 4b85dfc

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

invokeai/frontend/web/public/locales/en.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,11 +1052,7 @@
10521052
"remixImage": "Remix Image",
10531053
"usePrompt": "Use Prompt",
10541054
"useSeed": "Use Seed",
1055-
"width": "Width",
1056-
"isAllowedToUpscale": {
1057-
"useX2Model": "Image is too large to upscale with x4 model, use x2 model",
1058-
"tooLarge": "Image is too large to upscale, select smaller image"
1059-
}
1055+
"width": "Width"
10601056
},
10611057
"dynamicPrompts": {
10621058
"showDynamicPrompts": "Show Dynamic Prompts",
@@ -1684,6 +1680,8 @@
16841680
"postProcessingMissingModelWarning": "Visit the <LinkComponent>Model Manager</LinkComponent> to install a post-processing (image to image) model.",
16851681
"missingModelsWarning": "Visit the <LinkComponent>Model Manager</LinkComponent> to install the required models:",
16861682
"mainModelDesc": "Main model (SD1.5 or SDXL architecture)",
1683+
"outputTooLargeShort": "Output is too large to upscale",
1684+
"outputTooLarge": "Max upscale limit is 10,000x10,000 pixels. Please try a smaller image or decrease your scale selection.",
16871685
"tileControlNetModelDesc": "Tile ControlNet model for the chosen main model architecture",
16881686
"upscaleModelDesc": "Upscale (image to image) model",
16891687
"missingUpscaleInitialImage": "Missing initial image for upscaling",

invokeai/frontend/web/src/app/types/invokeai.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export type AppConfig = {
6565
*/
6666
shouldUpdateImagesOnConnect: boolean;
6767
shouldFetchMetadataFromApi: boolean;
68+
maxUpscalePixels?: number;
6869
allowPrivateBoards: boolean;
6970
disabledTabs: InvokeTabName[];
7071
disabledFeatures: AppFeature[];

invokeai/frontend/web/src/common/hooks/useIsReadyToEnqueue.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { selectWorkflowSettingsSlice } from 'features/nodes/store/workflowSettin
1616
import { isInvocationNode } from 'features/nodes/types/invocation';
1717
import { selectGenerationSlice } from 'features/parameters/store/generationSlice';
1818
import { selectUpscalelice } from 'features/parameters/store/upscaleSlice';
19+
import { selectConfigSlice } from 'features/system/store/configSlice';
1920
import { selectSystemSlice } from 'features/system/store/systemSlice';
2021
import { activeTabNameSelector } from 'features/ui/store/uiSelectors';
2122
import i18n from 'i18next';
@@ -42,6 +43,7 @@ const createSelector = (templates: Templates) =>
4243
selectControlLayersSlice,
4344
activeTabNameSelector,
4445
selectUpscalelice,
46+
selectConfigSlice,
4547
],
4648
(
4749
controlAdapters,
@@ -52,7 +54,8 @@ const createSelector = (templates: Templates) =>
5254
dynamicPrompts,
5355
controlLayers,
5456
activeTabName,
55-
upscale
57+
upscale,
58+
config
5659
) => {
5760
const { model } = generation;
5861
const { size } = controlLayers.present;
@@ -209,6 +212,12 @@ const createSelector = (templates: Templates) =>
209212
} else if (activeTabName === 'upscaling') {
210213
if (!upscale.upscaleInitialImage) {
211214
reasons.push({ content: i18n.t('upscaling.missingUpscaleInitialImage') });
215+
} else if (config.maxUpscalePixels) {
216+
const upscaledPixels =
217+
upscale.upscaleInitialImage.width * upscale.scale * upscale.upscaleInitialImage.height * upscale.scale;
218+
if (upscaledPixels > config.maxUpscalePixels) {
219+
reasons.push({ content: i18n.t('upscaling.outputTooLargeShort') });
220+
}
212221
}
213222
if (!upscale.upscaleModel) {
214223
reasons.push({ content: i18n.t('upscaling.missingUpscaleModel') });

invokeai/frontend/web/src/features/parameters/hooks/useIsTooLargeToUpscale.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,20 @@ import { selectConfigSlice } from 'features/system/store/configSlice';
55
import { useMemo } from 'react';
66
import type { ImageDTO } from 'services/api/types';
77

8-
98
export const createIsTooLargeToUpscaleSelector = (imageDTO?: ImageDTO) =>
109
createMemoizedSelector(selectUpscalelice, selectConfigSlice, (upscale, config) => {
1110
const { upscaleModel, scale } = upscale;
1211
const { maxUpscalePixels } = config;
1312

1413
if (!maxUpscalePixels || !upscaleModel || !imageDTO) {
15-
return false
14+
return false;
1615
}
1716

1817
const upscaledPixels = imageDTO.width * scale * imageDTO.height * scale;
19-
console.log({ upscaledPixels })
20-
console.log({ maxUpscalePixels })
21-
return upscaledPixels > maxUpscalePixels
22-
18+
return upscaledPixels > maxUpscalePixels;
2319
});
2420

2521
export const useIsTooLargeToUpscale = (imageDTO?: ImageDTO) => {
2622
const selectIsTooLargeToUpscale = useMemo(() => createIsTooLargeToUpscaleSelector(imageDTO), [imageDTO]);
2723
return useAppSelector(selectIsTooLargeToUpscale);
28-
};
24+
};

invokeai/frontend/web/src/features/settingsAccordions/components/UpscaleSettingsAccordion/UpscaleWarning.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Button, Flex, ListItem, Text, UnorderedList } from '@invoke-ai/ui-library';
22
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
33
import { $installModelsTab } from 'features/modelManagerV2/subpanels/InstallModels';
4+
import { useIsTooLargeToUpscale } from 'features/parameters/hooks/useIsTooLargeToUpscale';
45
import { tileControlnetModelChanged } from 'features/parameters/store/upscaleSlice';
56
import { setActiveTab } from 'features/ui/store/uiSlice';
67
import { useCallback, useEffect, useMemo } from 'react';
78
import { Trans, useTranslation } from 'react-i18next';
89
import { useControlNetModels } from 'services/api/hooks/modelsByType';
9-
import { useIsTooLargeToUpscale } from '../../../parameters/hooks/useIsTooLargeToUpscale';
1010

1111
export const UpscaleWarning = () => {
1212
const { t } = useTranslation();
@@ -42,13 +42,12 @@ export const UpscaleWarning = () => {
4242
}, [model, tileControlnetModel, upscaleModel, t]);
4343

4444
const otherWarnings = useMemo(() => {
45-
console.log({ isTooLargeToUpscale });
4645
const _warnings: string[] = [];
4746
if (isTooLargeToUpscale) {
4847
_warnings.push(t('upscaling.outputTooLarge'));
4948
}
5049
return _warnings;
51-
}, [isTooLargeToUpscale]);
50+
}, [isTooLargeToUpscale, t]);
5251

5352
const handleGoToModelManager = useCallback(() => {
5453
dispatch(setActiveTab('models'));

0 commit comments

Comments
 (0)