mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
restore adhoc upscale button
This commit is contained in:
parent
3a2707ac02
commit
5a1ed99ca1
@ -11,8 +11,12 @@ import SingleSelectionMenuItems from 'features/gallery/components/ImageContextMe
|
|||||||
import { useImageActions } from 'features/gallery/hooks/useImageActions';
|
import { useImageActions } from 'features/gallery/hooks/useImageActions';
|
||||||
import { sentImageToImg2Img } from 'features/gallery/store/actions';
|
import { sentImageToImg2Img } from 'features/gallery/store/actions';
|
||||||
import { selectLastSelectedImage } from 'features/gallery/store/gallerySelectors';
|
import { selectLastSelectedImage } from 'features/gallery/store/gallerySelectors';
|
||||||
|
import { selectGallerySlice } from 'features/gallery/store/gallerySlice';
|
||||||
import { parseAndRecallImageDimensions } from 'features/metadata/util/handlers';
|
import { parseAndRecallImageDimensions } from 'features/metadata/util/handlers';
|
||||||
import { $templates } from 'features/nodes/store/nodesSlice';
|
import { $templates } from 'features/nodes/store/nodesSlice';
|
||||||
|
import ParamUpscalePopover from 'features/parameters/components/Upscale/ParamUpscaleSettings';
|
||||||
|
import { useIsQueueMutationInProgress } from 'features/queue/hooks/useIsQueueMutationInProgress';
|
||||||
|
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
|
||||||
import { selectSystemSlice } from 'features/system/store/systemSlice';
|
import { selectSystemSlice } from 'features/system/store/systemSlice';
|
||||||
import { setActiveTab } from 'features/ui/store/uiSlice';
|
import { setActiveTab } from 'features/ui/store/uiSlice';
|
||||||
import { useGetAndLoadEmbeddedWorkflow } from 'features/workflowLibrary/hooks/useGetAndLoadEmbeddedWorkflow';
|
import { useGetAndLoadEmbeddedWorkflow } from 'features/workflowLibrary/hooks/useGetAndLoadEmbeddedWorkflow';
|
||||||
@ -33,8 +37,9 @@ import { useGetImageDTOQuery } from 'services/api/endpoints/images';
|
|||||||
|
|
||||||
const selectShouldDisableToolbarButtons = createSelector(
|
const selectShouldDisableToolbarButtons = createSelector(
|
||||||
selectSystemSlice,
|
selectSystemSlice,
|
||||||
|
selectGallerySlice,
|
||||||
selectLastSelectedImage,
|
selectLastSelectedImage,
|
||||||
(system, lastSelectedImage) => {
|
(system, gallery, lastSelectedImage) => {
|
||||||
const hasProgressImage = Boolean(system.denoiseProgress?.progress_image);
|
const hasProgressImage = Boolean(system.denoiseProgress?.progress_image);
|
||||||
return hasProgressImage || !lastSelectedImage;
|
return hasProgressImage || !lastSelectedImage;
|
||||||
}
|
}
|
||||||
@ -42,10 +47,13 @@ const selectShouldDisableToolbarButtons = createSelector(
|
|||||||
|
|
||||||
const CurrentImageButtons = () => {
|
const CurrentImageButtons = () => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
const isConnected = useAppSelector((s) => s.system.isConnected);
|
||||||
const lastSelectedImage = useAppSelector(selectLastSelectedImage);
|
const lastSelectedImage = useAppSelector(selectLastSelectedImage);
|
||||||
const selection = useAppSelector((s) => s.gallery.selection);
|
const selection = useAppSelector((s) => s.gallery.selection);
|
||||||
const shouldDisableToolbarButtons = useAppSelector(selectShouldDisableToolbarButtons);
|
const shouldDisableToolbarButtons = useAppSelector(selectShouldDisableToolbarButtons);
|
||||||
const templates = useStore($templates);
|
const templates = useStore($templates);
|
||||||
|
const isUpscalingEnabled = useFeatureStatus('upscaling');
|
||||||
|
const isQueueMutationInProgress = useIsQueueMutationInProgress();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { currentData: imageDTO } = useGetImageDTOQuery(lastSelectedImage?.image_name ?? skipToken);
|
const { currentData: imageDTO } = useGetImageDTOQuery(lastSelectedImage?.image_name ?? skipToken);
|
||||||
@ -99,6 +107,17 @@ const CurrentImageButtons = () => {
|
|||||||
dispatch(imagesToDeleteSelected(selection));
|
dispatch(imagesToDeleteSelected(selection));
|
||||||
}, [dispatch, imageDTO, selection]);
|
}, [dispatch, imageDTO, selection]);
|
||||||
|
|
||||||
|
useHotkeys(
|
||||||
|
'Shift+U',
|
||||||
|
() => {
|
||||||
|
handleClickUpscale();
|
||||||
|
},
|
||||||
|
{
|
||||||
|
enabled: () => Boolean(isUpscalingEnabled && !shouldDisableToolbarButtons && isConnected),
|
||||||
|
},
|
||||||
|
[isUpscalingEnabled, imageDTO, shouldDisableToolbarButtons, isConnected]
|
||||||
|
);
|
||||||
|
|
||||||
useHotkeys(
|
useHotkeys(
|
||||||
'delete',
|
'delete',
|
||||||
() => {
|
() => {
|
||||||
@ -172,6 +191,12 @@ const CurrentImageButtons = () => {
|
|||||||
/>
|
/>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
|
|
||||||
|
{isUpscalingEnabled && (
|
||||||
|
<ButtonGroup isDisabled={isQueueMutationInProgress}>
|
||||||
|
{isUpscalingEnabled && <ParamUpscalePopover imageDTO={imageDTO} />}
|
||||||
|
</ButtonGroup>
|
||||||
|
)}
|
||||||
|
|
||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
<DeleteImageButton onClick={handleDelete} />
|
<DeleteImageButton onClick={handleDelete} />
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
|
@ -17,8 +17,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { PiFrameCornersBold } from 'react-icons/pi';
|
import { PiFrameCornersBold } from 'react-icons/pi';
|
||||||
import type { ImageDTO } from 'services/api/types';
|
import type { ImageDTO } from 'services/api/types';
|
||||||
|
|
||||||
import ParamSpandrelModel from './ParamSpandrelModel';
|
import ParamESRGANModel from './ParamRealESRGANModel';
|
||||||
import { useSpandrelImageToImageModels } from '../../../../services/api/hooks/modelsByType';
|
|
||||||
|
|
||||||
type Props = { imageDTO?: ImageDTO };
|
type Props = { imageDTO?: ImageDTO };
|
||||||
|
|
||||||
@ -29,7 +28,6 @@ const ParamUpscalePopover = (props: Props) => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||||
const { isAllowedToUpscale, detail } = useIsAllowedToUpscale(imageDTO);
|
const { isAllowedToUpscale, detail } = useIsAllowedToUpscale(imageDTO);
|
||||||
const [modelConfigs] = useSpandrelImageToImageModels();
|
|
||||||
|
|
||||||
const handleClickUpscale = useCallback(() => {
|
const handleClickUpscale = useCallback(() => {
|
||||||
onClose();
|
onClose();
|
||||||
@ -47,17 +45,16 @@ const ParamUpscalePopover = (props: Props) => {
|
|||||||
onClick={onOpen}
|
onClick={onOpen}
|
||||||
icon={<PiFrameCornersBold />}
|
icon={<PiFrameCornersBold />}
|
||||||
aria-label={t('parameters.upscale')}
|
aria-label={t('parameters.upscale')}
|
||||||
isDisabled={!modelConfigs.length}
|
|
||||||
/>
|
/>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent>
|
<PopoverContent>
|
||||||
<PopoverBody minW={96}>
|
<PopoverBody minW={96}>
|
||||||
<Flex flexDirection="column" gap={4}>
|
<Flex flexDirection="column" gap={4}>
|
||||||
<ParamSpandrelModel />
|
<ParamESRGANModel />
|
||||||
<Button
|
<Button
|
||||||
tooltip={detail}
|
tooltip={detail}
|
||||||
size="sm"
|
size="sm"
|
||||||
isDisabled={!imageDTO || inProgress || !isAllowedToUpscale || !modelConfigs.length}
|
isDisabled={!imageDTO || inProgress || !isAllowedToUpscale}
|
||||||
onClick={handleClickUpscale}
|
onClick={handleClickUpscale}
|
||||||
>
|
>
|
||||||
{t('parameters.upscaleImage')}
|
{t('parameters.upscaleImage')}
|
||||||
|
Loading…
Reference in New Issue
Block a user