mirror of
https://github.com/invoke-ai/InvokeAI
synced 2026-03-13 02:10:20 +01:00
Use Optional instead of Nullable for mask settings
This commit is contained in:
parent
231bc18188
commit
12934da390
@ -37,7 +37,7 @@ export const InpaintMaskDenoiseLimitSlider = memo(() => {
|
||||
dispatch(inpaintMaskDenoiseLimitDeleted({ entityIdentifier }));
|
||||
}, [dispatch, entityIdentifier]);
|
||||
|
||||
if (denoiseLimit === null) {
|
||||
if (denoiseLimit === undefined) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ export const InpaintMaskNoiseSlider = memo(() => {
|
||||
dispatch(inpaintMaskNoiseDeleted({ entityIdentifier }));
|
||||
}, [dispatch, entityIdentifier]);
|
||||
|
||||
if (noiseLevel === null) {
|
||||
if (noiseLevel === undefined) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -13,8 +13,8 @@ const buildSelectFlags = (entityIdentifier: CanvasEntityIdentifier<'inpaint_mask
|
||||
createMemoizedSelector(selectCanvasSlice, (canvas) => {
|
||||
const entity = selectEntityOrThrow(canvas, entityIdentifier, 'InpaintMaskSettings');
|
||||
return {
|
||||
hasNoiseLevel: entity.noiseLevel !== null,
|
||||
hasDenoiseLimit: entity.denoiseLimit !== null,
|
||||
hasNoiseLevel: entity.noiseLevel !== undefined,
|
||||
hasDenoiseLimit: entity.denoiseLimit !== undefined,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@ -498,7 +498,7 @@ export class CanvasCompositorModule extends CanvasModuleBase {
|
||||
const imageData = tempCtx.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
|
||||
const data = imageData.data;
|
||||
|
||||
const attributeValue = typeof adapter.state[attribute] === 'number' ? (adapter.state[attribute] as number) : 1.0; // Default to full strength if attribute is not a number
|
||||
const attributeValue = typeof adapter.state[attribute] === 'number' ? (adapter.state[attribute] as number) : 1.0; // Default to full strength if attribute is undefined
|
||||
|
||||
// Process all pixels in the image data
|
||||
for (let i = 0; i < data.length; i += 4) {
|
||||
|
||||
@ -1117,7 +1117,7 @@ export const canvasSlice = createSlice({
|
||||
const { entityIdentifier } = action.payload;
|
||||
const entity = selectEntity(state, entityIdentifier);
|
||||
if (entity && entity.type === 'inpaint_mask') {
|
||||
entity.noiseLevel = null;
|
||||
entity.noiseLevel = undefined;
|
||||
}
|
||||
},
|
||||
inpaintMaskConvertedToRegionalGuidance: {
|
||||
@ -1179,7 +1179,7 @@ export const canvasSlice = createSlice({
|
||||
const { entityIdentifier } = action.payload;
|
||||
const entity = selectEntity(state, entityIdentifier);
|
||||
if (entity && entity.type === 'inpaint_mask') {
|
||||
entity.denoiseLimit = null;
|
||||
entity.denoiseLimit = undefined;
|
||||
}
|
||||
},
|
||||
//#region BBox
|
||||
|
||||
@ -310,8 +310,8 @@ const zCanvasInpaintMaskState = zCanvasEntityBase.extend({
|
||||
fill: zFill,
|
||||
opacity: zOpacity,
|
||||
objects: z.array(zCanvasObjectState),
|
||||
noiseLevel: z.number().gte(0).lte(1).nullable().default(null),
|
||||
denoiseLimit: z.number().gte(0).lte(1).nullable().default(null),
|
||||
noiseLevel: z.number().gte(0).lte(1).optional(),
|
||||
denoiseLimit: z.number().gte(0).lte(1).optional(),
|
||||
});
|
||||
export type CanvasInpaintMaskState = z.infer<typeof zCanvasInpaintMaskState>;
|
||||
|
||||
|
||||
@ -199,8 +199,8 @@ export const getInpaintMaskState = (
|
||||
style: 'diagonal',
|
||||
color: getInpaintMaskFillColor(),
|
||||
},
|
||||
noiseLevel: null,
|
||||
denoiseLimit: null,
|
||||
noiseLevel: undefined,
|
||||
denoiseLimit: undefined,
|
||||
};
|
||||
merge(entityState, overrides);
|
||||
return entityState;
|
||||
|
||||
@ -66,7 +66,7 @@ export const addInpaint = async ({
|
||||
const inpaintMaskAdapters = manager.compositor.getVisibleAdaptersOfType('inpaint_mask');
|
||||
|
||||
// Get inpaint mask adapters that have noise settings
|
||||
const noiseMaskAdapters = inpaintMaskAdapters.filter((adapter) => adapter.state.noiseLevel !== null);
|
||||
const noiseMaskAdapters = inpaintMaskAdapters.filter((adapter) => adapter.state.noiseLevel !== undefined);
|
||||
|
||||
// Create a composite noise mask if we have any adapters with noise settings
|
||||
let noiseMaskImage = null;
|
||||
|
||||
@ -69,7 +69,7 @@ export const addOutpaint = async ({
|
||||
const rect: Rect = canvas.bbox?.rect ?? getEmptyRect();
|
||||
|
||||
// Get inpaint mask adapters that have noise settings
|
||||
const noiseMaskAdapters = inpaintMaskAdapters.filter((adapter) => adapter.state.noiseLevel !== null);
|
||||
const noiseMaskAdapters = inpaintMaskAdapters.filter((adapter) => adapter.state.noiseLevel !== undefined);
|
||||
|
||||
// Create a composite noise mask if we have any adapters with noise settings
|
||||
let noiseMaskImage = null;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user