(ui): restore optioanl limit on upcsale output resolution

This commit is contained in:
Mary Hipp
2024-08-05 11:58:17 -04:00
committed by psychedelicious
parent 21deefdc41
commit 4b85dfcefe
5 changed files with 19 additions and 16 deletions

View File

@ -5,24 +5,20 @@ import { selectConfigSlice } from 'features/system/store/configSlice';
import { useMemo } from 'react';
import type { ImageDTO } from 'services/api/types';
export const createIsTooLargeToUpscaleSelector = (imageDTO?: ImageDTO) =>
createMemoizedSelector(selectUpscalelice, selectConfigSlice, (upscale, config) => {
const { upscaleModel, scale } = upscale;
const { maxUpscalePixels } = config;
if (!maxUpscalePixels || !upscaleModel || !imageDTO) {
return false
return false;
}
const upscaledPixels = imageDTO.width * scale * imageDTO.height * scale;
console.log({ upscaledPixels })
console.log({ maxUpscalePixels })
return upscaledPixels > maxUpscalePixels
return upscaledPixels > maxUpscalePixels;
});
export const useIsTooLargeToUpscale = (imageDTO?: ImageDTO) => {
const selectIsTooLargeToUpscale = useMemo(() => createIsTooLargeToUpscaleSelector(imageDTO), [imageDTO]);
return useAppSelector(selectIsTooLargeToUpscale);
};
};

View File

@ -1,12 +1,12 @@
import { Button, Flex, ListItem, Text, UnorderedList } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { $installModelsTab } from 'features/modelManagerV2/subpanels/InstallModels';
import { useIsTooLargeToUpscale } from 'features/parameters/hooks/useIsTooLargeToUpscale';
import { tileControlnetModelChanged } from 'features/parameters/store/upscaleSlice';
import { setActiveTab } from 'features/ui/store/uiSlice';
import { useCallback, useEffect, useMemo } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { useControlNetModels } from 'services/api/hooks/modelsByType';
import { useIsTooLargeToUpscale } from '../../../parameters/hooks/useIsTooLargeToUpscale';
export const UpscaleWarning = () => {
const { t } = useTranslation();
@ -42,13 +42,12 @@ export const UpscaleWarning = () => {
}, [model, tileControlnetModel, upscaleModel, t]);
const otherWarnings = useMemo(() => {
console.log({ isTooLargeToUpscale });
const _warnings: string[] = [];
if (isTooLargeToUpscale) {
_warnings.push(t('upscaling.outputTooLarge'));
}
return _warnings;
}, [isTooLargeToUpscale]);
}, [isTooLargeToUpscale, t]);
const handleGoToModelManager = useCallback(() => {
dispatch(setActiveTab('models'));