mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
(ui): restore optioanl limit on upcsale output resolution
This commit is contained in:
committed by
psychedelicious
parent
21deefdc41
commit
4b85dfcefe
@ -1052,11 +1052,7 @@
|
|||||||
"remixImage": "Remix Image",
|
"remixImage": "Remix Image",
|
||||||
"usePrompt": "Use Prompt",
|
"usePrompt": "Use Prompt",
|
||||||
"useSeed": "Use Seed",
|
"useSeed": "Use Seed",
|
||||||
"width": "Width",
|
"width": "Width"
|
||||||
"isAllowedToUpscale": {
|
|
||||||
"useX2Model": "Image is too large to upscale with x4 model, use x2 model",
|
|
||||||
"tooLarge": "Image is too large to upscale, select smaller image"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"dynamicPrompts": {
|
"dynamicPrompts": {
|
||||||
"showDynamicPrompts": "Show Dynamic Prompts",
|
"showDynamicPrompts": "Show Dynamic Prompts",
|
||||||
@ -1684,6 +1680,8 @@
|
|||||||
"postProcessingMissingModelWarning": "Visit the <LinkComponent>Model Manager</LinkComponent> to install a post-processing (image to image) model.",
|
"postProcessingMissingModelWarning": "Visit the <LinkComponent>Model Manager</LinkComponent> to install a post-processing (image to image) model.",
|
||||||
"missingModelsWarning": "Visit the <LinkComponent>Model Manager</LinkComponent> to install the required models:",
|
"missingModelsWarning": "Visit the <LinkComponent>Model Manager</LinkComponent> to install the required models:",
|
||||||
"mainModelDesc": "Main model (SD1.5 or SDXL architecture)",
|
"mainModelDesc": "Main model (SD1.5 or SDXL architecture)",
|
||||||
|
"outputTooLargeShort": "Output is too large to upscale",
|
||||||
|
"outputTooLarge": "Max upscale limit is 10,000x10,000 pixels. Please try a smaller image or decrease your scale selection.",
|
||||||
"tileControlNetModelDesc": "Tile ControlNet model for the chosen main model architecture",
|
"tileControlNetModelDesc": "Tile ControlNet model for the chosen main model architecture",
|
||||||
"upscaleModelDesc": "Upscale (image to image) model",
|
"upscaleModelDesc": "Upscale (image to image) model",
|
||||||
"missingUpscaleInitialImage": "Missing initial image for upscaling",
|
"missingUpscaleInitialImage": "Missing initial image for upscaling",
|
||||||
|
@ -65,6 +65,7 @@ export type AppConfig = {
|
|||||||
*/
|
*/
|
||||||
shouldUpdateImagesOnConnect: boolean;
|
shouldUpdateImagesOnConnect: boolean;
|
||||||
shouldFetchMetadataFromApi: boolean;
|
shouldFetchMetadataFromApi: boolean;
|
||||||
|
maxUpscalePixels?: number;
|
||||||
allowPrivateBoards: boolean;
|
allowPrivateBoards: boolean;
|
||||||
disabledTabs: InvokeTabName[];
|
disabledTabs: InvokeTabName[];
|
||||||
disabledFeatures: AppFeature[];
|
disabledFeatures: AppFeature[];
|
||||||
|
@ -16,6 +16,7 @@ import { selectWorkflowSettingsSlice } from 'features/nodes/store/workflowSettin
|
|||||||
import { isInvocationNode } from 'features/nodes/types/invocation';
|
import { isInvocationNode } from 'features/nodes/types/invocation';
|
||||||
import { selectGenerationSlice } from 'features/parameters/store/generationSlice';
|
import { selectGenerationSlice } from 'features/parameters/store/generationSlice';
|
||||||
import { selectUpscalelice } from 'features/parameters/store/upscaleSlice';
|
import { selectUpscalelice } from 'features/parameters/store/upscaleSlice';
|
||||||
|
import { selectConfigSlice } from 'features/system/store/configSlice';
|
||||||
import { selectSystemSlice } from 'features/system/store/systemSlice';
|
import { selectSystemSlice } from 'features/system/store/systemSlice';
|
||||||
import { activeTabNameSelector } from 'features/ui/store/uiSelectors';
|
import { activeTabNameSelector } from 'features/ui/store/uiSelectors';
|
||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
||||||
@ -42,6 +43,7 @@ const createSelector = (templates: Templates) =>
|
|||||||
selectControlLayersSlice,
|
selectControlLayersSlice,
|
||||||
activeTabNameSelector,
|
activeTabNameSelector,
|
||||||
selectUpscalelice,
|
selectUpscalelice,
|
||||||
|
selectConfigSlice,
|
||||||
],
|
],
|
||||||
(
|
(
|
||||||
controlAdapters,
|
controlAdapters,
|
||||||
@ -52,7 +54,8 @@ const createSelector = (templates: Templates) =>
|
|||||||
dynamicPrompts,
|
dynamicPrompts,
|
||||||
controlLayers,
|
controlLayers,
|
||||||
activeTabName,
|
activeTabName,
|
||||||
upscale
|
upscale,
|
||||||
|
config
|
||||||
) => {
|
) => {
|
||||||
const { model } = generation;
|
const { model } = generation;
|
||||||
const { size } = controlLayers.present;
|
const { size } = controlLayers.present;
|
||||||
@ -209,6 +212,12 @@ const createSelector = (templates: Templates) =>
|
|||||||
} else if (activeTabName === 'upscaling') {
|
} else if (activeTabName === 'upscaling') {
|
||||||
if (!upscale.upscaleInitialImage) {
|
if (!upscale.upscaleInitialImage) {
|
||||||
reasons.push({ content: i18n.t('upscaling.missingUpscaleInitialImage') });
|
reasons.push({ content: i18n.t('upscaling.missingUpscaleInitialImage') });
|
||||||
|
} else if (config.maxUpscalePixels) {
|
||||||
|
const upscaledPixels =
|
||||||
|
upscale.upscaleInitialImage.width * upscale.scale * upscale.upscaleInitialImage.height * upscale.scale;
|
||||||
|
if (upscaledPixels > config.maxUpscalePixels) {
|
||||||
|
reasons.push({ content: i18n.t('upscaling.outputTooLargeShort') });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!upscale.upscaleModel) {
|
if (!upscale.upscaleModel) {
|
||||||
reasons.push({ content: i18n.t('upscaling.missingUpscaleModel') });
|
reasons.push({ content: i18n.t('upscaling.missingUpscaleModel') });
|
||||||
|
@ -5,21 +5,17 @@ import { selectConfigSlice } from 'features/system/store/configSlice';
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import type { ImageDTO } from 'services/api/types';
|
import type { ImageDTO } from 'services/api/types';
|
||||||
|
|
||||||
|
|
||||||
export const createIsTooLargeToUpscaleSelector = (imageDTO?: ImageDTO) =>
|
export const createIsTooLargeToUpscaleSelector = (imageDTO?: ImageDTO) =>
|
||||||
createMemoizedSelector(selectUpscalelice, selectConfigSlice, (upscale, config) => {
|
createMemoizedSelector(selectUpscalelice, selectConfigSlice, (upscale, config) => {
|
||||||
const { upscaleModel, scale } = upscale;
|
const { upscaleModel, scale } = upscale;
|
||||||
const { maxUpscalePixels } = config;
|
const { maxUpscalePixels } = config;
|
||||||
|
|
||||||
if (!maxUpscalePixels || !upscaleModel || !imageDTO) {
|
if (!maxUpscalePixels || !upscaleModel || !imageDTO) {
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const upscaledPixels = imageDTO.width * scale * imageDTO.height * scale;
|
const upscaledPixels = imageDTO.width * scale * imageDTO.height * scale;
|
||||||
console.log({ upscaledPixels })
|
return upscaledPixels > maxUpscalePixels;
|
||||||
console.log({ maxUpscalePixels })
|
|
||||||
return upscaledPixels > maxUpscalePixels
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const useIsTooLargeToUpscale = (imageDTO?: ImageDTO) => {
|
export const useIsTooLargeToUpscale = (imageDTO?: ImageDTO) => {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { Button, Flex, ListItem, Text, UnorderedList } from '@invoke-ai/ui-library';
|
import { Button, Flex, ListItem, Text, UnorderedList } from '@invoke-ai/ui-library';
|
||||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
import { $installModelsTab } from 'features/modelManagerV2/subpanels/InstallModels';
|
import { $installModelsTab } from 'features/modelManagerV2/subpanels/InstallModels';
|
||||||
|
import { useIsTooLargeToUpscale } from 'features/parameters/hooks/useIsTooLargeToUpscale';
|
||||||
import { tileControlnetModelChanged } from 'features/parameters/store/upscaleSlice';
|
import { tileControlnetModelChanged } from 'features/parameters/store/upscaleSlice';
|
||||||
import { setActiveTab } from 'features/ui/store/uiSlice';
|
import { setActiveTab } from 'features/ui/store/uiSlice';
|
||||||
import { useCallback, useEffect, useMemo } from 'react';
|
import { useCallback, useEffect, useMemo } from 'react';
|
||||||
import { Trans, useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
import { useControlNetModels } from 'services/api/hooks/modelsByType';
|
import { useControlNetModels } from 'services/api/hooks/modelsByType';
|
||||||
import { useIsTooLargeToUpscale } from '../../../parameters/hooks/useIsTooLargeToUpscale';
|
|
||||||
|
|
||||||
export const UpscaleWarning = () => {
|
export const UpscaleWarning = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -42,13 +42,12 @@ export const UpscaleWarning = () => {
|
|||||||
}, [model, tileControlnetModel, upscaleModel, t]);
|
}, [model, tileControlnetModel, upscaleModel, t]);
|
||||||
|
|
||||||
const otherWarnings = useMemo(() => {
|
const otherWarnings = useMemo(() => {
|
||||||
console.log({ isTooLargeToUpscale });
|
|
||||||
const _warnings: string[] = [];
|
const _warnings: string[] = [];
|
||||||
if (isTooLargeToUpscale) {
|
if (isTooLargeToUpscale) {
|
||||||
_warnings.push(t('upscaling.outputTooLarge'));
|
_warnings.push(t('upscaling.outputTooLarge'));
|
||||||
}
|
}
|
||||||
return _warnings;
|
return _warnings;
|
||||||
}, [isTooLargeToUpscale]);
|
}, [isTooLargeToUpscale, t]);
|
||||||
|
|
||||||
const handleGoToModelManager = useCallback(() => {
|
const handleGoToModelManager = useCallback(() => {
|
||||||
dispatch(setActiveTab('models'));
|
dispatch(setActiveTab('models'));
|
||||||
|
Reference in New Issue
Block a user