Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple upscale bugfixes #6655

Merged
merged 4 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { logger } from 'app/logging/logger';
import type { AppStartListening } from 'app/store/middleware/listenerMiddleware';
import { parseify } from 'common/util/serialize';
import { buildAdHocUpscaleGraph } from 'features/nodes/util/graph/buildAdHocUpscaleGraph';
import { createIsAllowedToUpscaleSelector } from 'features/parameters/hooks/useIsAllowedToUpscale';
import { toast } from 'features/toast/toast';
import { t } from 'i18next';
import { queueApi } from 'services/api/endpoints/queue';
Expand All @@ -20,22 +19,6 @@ export const addUpscaleRequestedListener = (startAppListening: AppStartListening
const { imageDTO } = action.payload;
const state = getState();

const { isAllowedToUpscale, detailTKey } = createIsAllowedToUpscaleSelector(imageDTO)(state);

// if we can't upscale, show a toast and return
if (!isAllowedToUpscale) {
log.error(
{ imageDTO },
t(detailTKey ?? 'parameters.isAllowedToUpscale.tooLarge') // should never coalesce
);
toast({
id: 'NOT_ALLOWED_TO_UPSCALE',
title: t(detailTKey ?? 'parameters.isAllowedToUpscale.tooLarge'), // should never coalesce
status: 'error',
});
return;
}

const enqueueBatchArg: BatchConfig = {
prepend: true,
batch: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { RootState } from 'app/store/store';
import { fetchModelConfigWithTypeGuard } from 'features/metadata/util/modelFetchingHelpers';
import { getBoardField } from 'features/nodes/util/graph/graphBuilderUtils';
import {
type ImageDTO,
type Invocation,
Expand Down Expand Up @@ -27,6 +28,7 @@ export const buildAdHocUpscaleGraph = async ({ image, state }: Arg): Promise<Non
image_to_image_model: simpleUpscaleModel,
tile_size: 500,
image,
board: getBoardField(state),
};

const graph: NonNullableGraph = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import {
useDisclosure,
} from '@invoke-ai/ui-library';
import { upscaleRequested } from 'app/store/middleware/listenerMiddleware/listeners/upscaleRequested';
import { useAppDispatch } from 'app/store/storeHooks';
import { useIsAllowedToUpscale } from 'features/parameters/hooks/useIsAllowedToUpscale';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { useIsQueueMutationInProgress } from 'features/queue/hooks/useIsQueueMutationInProgress';
import { UpscaleWarning } from 'features/settingsAccordions/components/UpscaleSettingsAccordion/UpscaleWarning';
import { memo, useCallback } from 'react';
Expand All @@ -25,18 +24,18 @@ type Props = { imageDTO?: ImageDTO };
const ParamUpscalePopover = (props: Props) => {
const { imageDTO } = props;
const dispatch = useAppDispatch();
const { simpleUpscaleModel } = useAppSelector((s) => s.upscale);
const inProgress = useIsQueueMutationInProgress();
const { t } = useTranslation();
const { isOpen, onOpen, onClose } = useDisclosure();
const { isAllowedToUpscale, detail } = useIsAllowedToUpscale(imageDTO);

const handleClickUpscale = useCallback(() => {
onClose();
if (!imageDTO || !isAllowedToUpscale) {
if (!imageDTO) {
return;
}
dispatch(upscaleRequested({ imageDTO }));
}, [dispatch, imageDTO, isAllowedToUpscale, onClose]);
}, [dispatch, imageDTO, onClose]);

return (
<Popover isOpen={isOpen} onClose={onClose} isLazy>
Expand All @@ -53,12 +52,7 @@ const ParamUpscalePopover = (props: Props) => {
<Flex flexDirection="column" gap={4}>
<ParamSpandrelModel isMultidiffusion={false} />
<UpscaleWarning usesTile={false} />
<Button
tooltip={detail}
size="sm"
isDisabled={!imageDTO || inProgress || !isAllowedToUpscale}
onClick={handleClickUpscale}
>
<Button size="sm" isDisabled={!imageDTO || inProgress || !simpleUpscaleModel} onClick={handleClickUpscale}>
{t('parameters.upscaleImage')}
</Button>
</Flex>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Props {
export const UpscaleWarning = ({ usesTile }: Props) => {
const { t } = useTranslation();
const model = useAppSelector((s) => s.generation.model);
const { tileControlnetModel, upscaleModel } = useAppSelector((s) => s.upscale);
const { tileControlnetModel, upscaleModel, simpleUpscaleModel } = useAppSelector((s) => s.upscale);
const dispatch = useAppDispatch();
const [modelConfigs, { isLoading }] = useControlNetModels();
const disabledTabs = useAppSelector((s) => s.config.disabledTabs);
Expand All @@ -29,6 +29,12 @@ export const UpscaleWarning = ({ usesTile }: Props) => {

const warnings = useMemo(() => {
const _warnings: string[] = [];
if (!usesTile) {
if (!simpleUpscaleModel) {
_warnings.push(t('upscaling.upscaleModelDesc'));
}
return _warnings;
}
if (!model) {
_warnings.push(t('upscaling.mainModelDesc'));
}
Expand All @@ -39,7 +45,7 @@ export const UpscaleWarning = ({ usesTile }: Props) => {
_warnings.push(t('upscaling.upscaleModelDesc'));
}
return _warnings;
}, [model, upscaleModel, tileControlnetModel, usesTile, t]);
}, [model, upscaleModel, tileControlnetModel, usesTile, simpleUpscaleModel, t]);

const handleGoToModelManager = useCallback(() => {
dispatch(setActiveTab('models'));
Expand Down
Loading