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

fix, feat: canvas followups 15 #6919

Merged
merged 20 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c6d5fe4
feat(nodes): mark core metadata internal
psychedelicious Sep 22, 2024
1aef537
feat(ui): add Fit Bbox to Canvas hotkey
psychedelicious Sep 22, 2024
d83ec41
feat(ui): add color swatches to mask fill
psychedelicious Sep 22, 2024
8520d93
fix(ui): less janky logic w/ sending-to alerts
psychedelicious Sep 22, 2024
47a3441
tidy(ui): typo
psychedelicious Sep 22, 2024
21f24c0
feat(ui): split up StagingAreaToolbar
psychedelicious Sep 22, 2024
e0121a4
feat(ui): on accept staged image, switch to raster layer if raster la…
psychedelicious Sep 23, 2024
db25c9b
feat(ui): move view buttons on canvas tool bar next to zoom
psychedelicious Sep 23, 2024
83b0da3
fix(ui): transform ui translations
psychedelicious Sep 23, 2024
92c7bce
feat(ui): canvas send-to alerts are not dismissable
psychedelicious Sep 23, 2024
3e021c8
fix(ui): flash of last staged image when accepting staging area
psychedelicious Sep 23, 2024
23af8be
fix(ui): lag when discarding staging area
psychedelicious Sep 23, 2024
72929da
fix(ui): hide tool preview when filtering
psychedelicious Sep 23, 2024
87b3a7a
feat(ui): rework isolated previewing
psychedelicious Sep 23, 2024
ae7e750
tweak(ui): align flux dev license money icon
psychedelicious Sep 23, 2024
19df076
feat(ui): revised modelsLoaded listener
psychedelicious Sep 23, 2024
710be7c
fix(ui): bbox not centered on very first app startup
psychedelicious Sep 23, 2024
96246d5
tidy(ui): remove use size from ip adapter image
psychedelicious Sep 23, 2024
2e5a292
feat(ui): handle FLUX bbox constraints
psychedelicious Sep 23, 2024
92c28b1
chore(ui): lint
psychedelicious Sep 23, 2024
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
19 changes: 16 additions & 3 deletions invokeai/app/invocations/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

from pydantic import BaseModel, ConfigDict, Field

from invokeai.app.invocations.baseinvocation import BaseInvocation, BaseInvocationOutput, invocation, invocation_output
from invokeai.app.invocations.baseinvocation import (
BaseInvocation,
BaseInvocationOutput,
Classification,
invocation,
invocation_output,
)
from invokeai.app.invocations.fields import (
FieldDescriptions,
ImageField,
Expand Down Expand Up @@ -144,9 +150,16 @@ def invoke(self, context: InvocationContext) -> MetadataOutput:
]


@invocation("core_metadata", title="Core Metadata", tags=["metadata"], category="metadata", version="2.0.0")
@invocation(
"core_metadata",
title="Core Metadata",
tags=["metadata"],
category="metadata",
version="2.0.0",
classification=Classification.Internal,
)
class CoreMetadataInvocation(BaseInvocation):
"""Collects core generation metadata into a MetadataField"""
"""Used internally by Invoke to collect metadata for generations."""

generation_mode: Optional[GENERATION_MODES] = InputField(
default=None,
Expand Down
21 changes: 18 additions & 3 deletions invokeai/frontend/web/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@
"title": "Fit Layers to Canvas",
"desc": "Scale and position the view to fit all visible layers."
},
"fitBboxToCanvas": {
"title": "Fit Bbox to Canvas",
"desc": "Scale and position the view to fit the bbox."
},
"setZoomTo100Percent": {
"title": "Zoom to 100%",
"desc": "Set the canvas zoom to 100%."
Expand Down Expand Up @@ -1002,7 +1006,11 @@
"noFLUXVAEModelSelected": "No VAE model selected for FLUX generation",
"noCLIPEmbedModelSelected": "No CLIP Embed model selected for FLUX generation",
"canvasManagerNotLoaded": "Canvas Manager not loaded",
"fluxModelIncompatibleDimensions": "FLUX requires image dimension to be multiples of 16",
"fluxRequiresDimensionsToBeMultipleOf16": "FLUX requires width/height to be multiple of 16",
"fluxModelIncompatibleBboxWidth": "$t(parameters.invoke.fluxRequiresDimensionsToBeMultipleOf16), bbox width is {{width}}",
"fluxModelIncompatibleBboxHeight": "$t(parameters.invoke.fluxRequiresDimensionsToBeMultipleOf16), bbox height is {{height}}",
"fluxModelIncompatibleScaledWidth": "$t(parameters.invoke.fluxRequiresDimensionsToBeMultipleOf16), scaled bbox width is {{width}}",
"fluxModelIncompatibleScaledHeight": "$t(parameters.invoke.fluxRequiresDimensionsToBeMultipleOf16), scaled bbox height is {{height}}",
"canvasIsFiltering": "Canvas is filtering",
"canvasIsTransforming": "Canvas is transforming",
"canvasIsRasterizing": "Canvas is rasterizing",
Expand All @@ -1016,7 +1024,11 @@
"controlAdapterIncompatibleBaseModel": "incompatible Control Adapter base model",
"controlAdapterNoImageSelected": "no Control Adapter image selected",
"controlAdapterImageNotProcessed": "Control Adapter image not processed",
"t2iAdapterIncompatibleDimensions": "T2I Adapter requires image dimension to be multiples of {{multiple}}",
"t2iAdapterRequiresDimensionsToBeMultipleOf": "T2I Adapter requires width/height to be multiple of",
"t2iAdapterIncompatibleBboxWidth": "$t(parameters.invoke.layer.t2iAdapterRequiresDimensionsToBeMultipleOf) {{multiple}}, bbox width is {{width}}",
"t2iAdapterIncompatibleBboxHeight": "$t(parameters.invoke.layer.t2iAdapterRequiresDimensionsToBeMultipleOf) {{multiple}}, bbox height is {{height}}",
"t2iAdapterIncompatibleScaledBboxWidth": "$t(parameters.invoke.layer.t2iAdapterRequiresDimensionsToBeMultipleOf) {{multiple}}, scaled bbox width is {{width}}",
"t2iAdapterIncompatibleScaledBboxHeight": "$t(parameters.invoke.layer.t2iAdapterRequiresDimensionsToBeMultipleOf) {{multiple}}, scaled bbox height is {{height}}",
"ipAdapterNoModelSelected": "no IP adapter selected",
"ipAdapterIncompatibleBaseModel": "incompatible IP Adapter base model",
"ipAdapterNoImageSelected": "no IP Adapter image selected",
Expand Down Expand Up @@ -1956,7 +1968,10 @@
"label": "Preserve Masked Region",
"alert": "Preserving Masked Region"
},
"showOnlyRasterLayersWhileStaging": "Show Only Raster Layers While Staging"
"isolatedPreview": "Isolated Preview",
"isolatedStagingPreview": "Isolated Staging Preview",
"isolatedFilteringPreview": "Isolated Filtering Preview",
"isolatedTransformingPreview": "Isolated Transforming Preview"
},
"HUD": {
"bbox": "Bbox",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,18 @@ import { isAnyOf } from '@reduxjs/toolkit';
import { logger } from 'app/logging/logger';
import type { AppStartListening } from 'app/store/middleware/listenerMiddleware';
import { canvasReset } from 'features/controlLayers/store/actions';
import { rasterLayerAdded } from 'features/controlLayers/store/canvasSlice';
import { stagingAreaImageAccepted, stagingAreaReset } from 'features/controlLayers/store/canvasStagingAreaSlice';
import { selectCanvasSlice } from 'features/controlLayers/store/selectors';
import type { CanvasRasterLayerState } from 'features/controlLayers/store/types';
import { imageDTOToImageObject } from 'features/controlLayers/store/util';
import { stagingAreaReset } from 'features/controlLayers/store/canvasStagingAreaSlice';
import { toast } from 'features/toast/toast';
import { t } from 'i18next';
import { queueApi } from 'services/api/endpoints/queue';
import { assert } from 'tsafe';

const log = logger('canvas');

const matchCanvasOrStagingAreaRest = isAnyOf(stagingAreaReset, canvasReset);
const matchCanvasOrStagingAreaReset = isAnyOf(stagingAreaReset, canvasReset);

export const addStagingListeners = (startAppListening: AppStartListening) => {
startAppListening({
matcher: matchCanvasOrStagingAreaRest,
matcher: matchCanvasOrStagingAreaReset,
effect: async (_, { dispatch }) => {
try {
const req = dispatch(
Expand Down Expand Up @@ -48,26 +43,4 @@ export const addStagingListeners = (startAppListening: AppStartListening) => {
}
},
});

startAppListening({
actionCreator: stagingAreaImageAccepted,
effect: (action, api) => {
const { index } = action.payload;
const state = api.getState();
const stagingAreaImage = state.canvasStagingArea.stagedImages[index];

assert(stagingAreaImage, 'No staged image found to accept');
const { x, y } = selectCanvasSlice(state).bbox.rect;

const { imageDTO, offsetX, offsetY } = stagingAreaImage;
const imageObject = imageDTOToImageObject(imageDTO);
const overrides: Partial<CanvasRasterLayerState> = {
position: { x: x + offsetX, y: y + offsetY },
objects: [imageObject],
};

api.dispatch(rasterLayerAdded({ overrides, isSelected: false }));
api.dispatch(stagingAreaReset());
},
});
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { logger } from 'app/logging/logger';
import type { AppStartListening } from 'app/store/middleware/listenerMiddleware';
import { bboxOptimalDimensionChanged, bboxSyncedToOptimalDimension } from 'features/controlLayers/store/canvasSlice';
import { bboxSyncedToOptimalDimension } from 'features/controlLayers/store/canvasSlice';
import { selectIsStaging } from 'features/controlLayers/store/canvasStagingAreaSlice';
import { loraDeleted } from 'features/controlLayers/store/lorasSlice';
import { modelChanged, vaeSelected } from 'features/controlLayers/store/paramsSlice';
import { modelSelected } from 'features/parameters/store/actions';
import { zParameterModel } from 'features/parameters/types/parameterSchemas';
import { getOptimalDimension } from 'features/parameters/util/optimalDimension';
import { toast } from 'features/toast/toast';
import { t } from 'i18next';

Expand Down Expand Up @@ -71,8 +70,6 @@ export const addModelSelectedListener = (startAppListening: AppStartListening) =
}

dispatch(modelChanged({ model: newModel, previousModel: state.params.model }));
// When staging, we don't want to change the bbox, but we must keep the optimal dimension in sync.
dispatch(bboxOptimalDimensionChanged({ optimalDimension: getOptimalDimension(newModel) }));
if (!selectIsStaging(state)) {
dispatch(bboxSyncedToOptimalDimension());
}
Expand Down
Loading
Loading