mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Adds infill method
This commit is contained in:
parent
ddfd82559f
commit
723dcf4236
@ -21,6 +21,7 @@ from threading import Event
|
||||
from ldm.invoke.args import Args, APP_ID, APP_VERSION, calculate_init_img_hash
|
||||
from ldm.invoke.pngwriter import PngWriter, retrieve_metadata
|
||||
from ldm.invoke.prompt_parser import split_weighted_subprompts
|
||||
from ldm.invoke.generator.inpaint import infill_methods
|
||||
|
||||
from backend.modules.parameters import parameters_to_command
|
||||
from backend.modules.get_canvas_generation_mode import (
|
||||
@ -286,6 +287,7 @@ class InvokeAIWebServer:
|
||||
print(f">> System config requested")
|
||||
config = self.get_system_config()
|
||||
config["model_list"] = self.generate.model_cache.list_models()
|
||||
config["infill_methods"] = infill_methods
|
||||
socketio.emit("systemConfig", config)
|
||||
|
||||
@socketio.on("requestModelChange")
|
||||
@ -821,6 +823,7 @@ class InvokeAIWebServer:
|
||||
generation_parameters.pop("seam_steps", None)
|
||||
generation_parameters.pop("tile_size", None)
|
||||
generation_parameters.pop("force_outpaint", None)
|
||||
generation_parameters.pop("infill_method", None)
|
||||
elif actual_generation_mode == "txt2img":
|
||||
generation_parameters["height"] = original_bounding_box["height"]
|
||||
generation_parameters["width"] = original_bounding_box["width"]
|
||||
@ -834,6 +837,7 @@ class InvokeAIWebServer:
|
||||
generation_parameters.pop("seam_steps", None)
|
||||
generation_parameters.pop("tile_size", None)
|
||||
generation_parameters.pop("force_outpaint", None)
|
||||
generation_parameters.pop("infill_method", None)
|
||||
|
||||
elif generation_parameters["generation_mode"] == "img2img":
|
||||
init_img_url = generation_parameters["init_img"]
|
||||
|
1
frontend/src/app/invokeai.d.ts
vendored
1
frontend/src/app/invokeai.d.ts
vendored
@ -155,6 +155,7 @@ export declare type SystemGenerationMetadata = {
|
||||
|
||||
export declare type SystemConfig = SystemGenerationMetadata & {
|
||||
model_list: ModelList;
|
||||
infill_methods: string[];
|
||||
};
|
||||
|
||||
export declare type ModelStatus = 'active' | 'cached' | 'not loaded';
|
||||
|
@ -29,6 +29,7 @@ import {
|
||||
|
||||
import {
|
||||
clearInitialImage,
|
||||
setInfillMethod,
|
||||
setInitialImage,
|
||||
setMaskPath,
|
||||
} from 'features/options/store/optionsSlice';
|
||||
@ -340,6 +341,9 @@ const makeSocketIOListeners = (
|
||||
},
|
||||
onSystemConfig: (data: InvokeAI.SystemConfig) => {
|
||||
dispatch(setSystemConfig(data));
|
||||
if (!data.infill_methods.includes('patchmatch')) {
|
||||
dispatch(setInfillMethod(data.infill_methods[0]));
|
||||
}
|
||||
},
|
||||
onModelChanged: (data: InvokeAI.ModelChangeResponse) => {
|
||||
const { model_name, model_list } = data;
|
||||
|
@ -46,6 +46,7 @@ export const frontendToBackendParameters = (
|
||||
height,
|
||||
hiresFix,
|
||||
img2imgStrength,
|
||||
infillMethod,
|
||||
initialImage,
|
||||
iterations,
|
||||
perlin,
|
||||
@ -190,6 +191,7 @@ export const frontendToBackendParameters = (
|
||||
generationParameters.seam_steps = seamSteps;
|
||||
generationParameters.tile_size = tileSize;
|
||||
generationParameters.force_outpaint = shouldForceOutpaint;
|
||||
generationParameters.infill_method = infillMethod;
|
||||
}
|
||||
|
||||
if (shouldGenerateVariations) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Box, Flex } from '@chakra-ui/react';
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import { useAppDispatch, useAppSelector } from 'app/store';
|
||||
import IAISelect from 'common/components/IAISelect';
|
||||
import IAISlider from 'common/components/IAISlider';
|
||||
import IAISwitch from 'common/components/IAISwitch';
|
||||
import { optionsSelector } from 'features/options/store/optionsSelectors';
|
||||
@ -11,28 +12,39 @@ import {
|
||||
setSeamSteps,
|
||||
setTileSize,
|
||||
setShouldForceOutpaint,
|
||||
setInfillMethod,
|
||||
} from 'features/options/store/optionsSlice';
|
||||
import { systemSelector } from 'features/system/store/systemSelectors';
|
||||
import { ChangeEvent } from 'react';
|
||||
import InpaintReplace from './InpaintReplace';
|
||||
|
||||
const selector = createSelector([optionsSelector], (options) => {
|
||||
const {
|
||||
seamSize,
|
||||
seamBlur,
|
||||
seamStrength,
|
||||
seamSteps,
|
||||
tileSize,
|
||||
shouldForceOutpaint,
|
||||
} = options;
|
||||
const selector = createSelector(
|
||||
[optionsSelector, systemSelector],
|
||||
(options, system) => {
|
||||
const {
|
||||
seamSize,
|
||||
seamBlur,
|
||||
seamStrength,
|
||||
seamSteps,
|
||||
tileSize,
|
||||
shouldForceOutpaint,
|
||||
infillMethod,
|
||||
} = options;
|
||||
|
||||
return {
|
||||
seamSize,
|
||||
seamBlur,
|
||||
seamStrength,
|
||||
seamSteps,
|
||||
tileSize,
|
||||
shouldForceOutpaint,
|
||||
};
|
||||
});
|
||||
const { infill_methods: availableInfillMethods } = system;
|
||||
|
||||
return {
|
||||
seamSize,
|
||||
seamBlur,
|
||||
seamStrength,
|
||||
seamSteps,
|
||||
tileSize,
|
||||
shouldForceOutpaint,
|
||||
infillMethod,
|
||||
availableInfillMethods,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
const OutpaintingOptions = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
@ -43,6 +55,8 @@ const OutpaintingOptions = () => {
|
||||
seamSteps,
|
||||
tileSize,
|
||||
shouldForceOutpaint,
|
||||
infillMethod,
|
||||
availableInfillMethods,
|
||||
} = useAppSelector(selector);
|
||||
|
||||
return (
|
||||
@ -115,7 +129,23 @@ const OutpaintingOptions = () => {
|
||||
withSliderMarks
|
||||
withReset
|
||||
/>
|
||||
<IAISwitch
|
||||
label={'Force Outpaint'}
|
||||
isChecked={shouldForceOutpaint}
|
||||
onChange={(e) => {
|
||||
dispatch(setShouldForceOutpaint(e.target.checked));
|
||||
}}
|
||||
/>
|
||||
<IAISelect
|
||||
label="Infill Method"
|
||||
value={infillMethod}
|
||||
validValues={availableInfillMethods}
|
||||
onChange={(e) => dispatch(setInfillMethod(e.target.value))}
|
||||
/>
|
||||
<IAISlider
|
||||
isInputDisabled={infillMethod !== 'tile'}
|
||||
isResetDisabled={infillMethod !== 'tile'}
|
||||
isSliderDisabled={infillMethod !== 'tile'}
|
||||
sliderMarkRightOffset={-4}
|
||||
label={'Tile Size'}
|
||||
min={16}
|
||||
@ -132,13 +162,6 @@ const OutpaintingOptions = () => {
|
||||
withSliderMarks
|
||||
withReset
|
||||
/>
|
||||
<IAISwitch
|
||||
label={'Force Outpaint'}
|
||||
isChecked={shouldForceOutpaint}
|
||||
onChange={(e) => {
|
||||
dispatch(setShouldForceOutpaint(e.target.checked));
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
@ -20,6 +20,7 @@ export interface OptionsState {
|
||||
height: number;
|
||||
hiresFix: boolean;
|
||||
img2imgStrength: number;
|
||||
infillMethod: string;
|
||||
initialImage?: InvokeAI.Image | string; // can be an Image or url
|
||||
isLightBoxOpen: boolean;
|
||||
iterations: number;
|
||||
@ -67,6 +68,7 @@ const initialOptionsState: OptionsState = {
|
||||
height: 512,
|
||||
hiresFix: false,
|
||||
img2imgStrength: 0.75,
|
||||
infillMethod: 'patchmatch',
|
||||
isLightBoxOpen: false,
|
||||
iterations: 1,
|
||||
maskPath: '',
|
||||
@ -390,6 +392,9 @@ export const optionsSlice = createSlice({
|
||||
setShouldForceOutpaint: (state, action: PayloadAction<boolean>) => {
|
||||
state.shouldForceOutpaint = action.payload;
|
||||
},
|
||||
setInfillMethod: (state, action: PayloadAction<string>) => {
|
||||
state.infillMethod = action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -409,6 +414,7 @@ export const {
|
||||
setHeight,
|
||||
setHiresFix,
|
||||
setImg2imgStrength,
|
||||
setInfillMethod,
|
||||
setInitialImage,
|
||||
setIsLightBoxOpen,
|
||||
setIterations,
|
||||
|
@ -72,6 +72,7 @@ const initialSystemState: SystemState = {
|
||||
app_id: '',
|
||||
app_version: '',
|
||||
model_list: {},
|
||||
infill_methods: [],
|
||||
hasError: false,
|
||||
wasErrorSeen: true,
|
||||
isCancelable: true,
|
||||
|
Loading…
Reference in New Issue
Block a user