Skip to content

Commit fb5ac78

Browse files
Merge branch 'lama-infill' of https://github.com/blessedcoolant/InvokeAI into lama-infill
2 parents 871b928 + c49b436 commit fb5ac78

15 files changed

+70
-36
lines changed

invokeai/app/invocations/infill.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,8 @@ class InfillPatchMatchInvocation(BaseInvocation):
196196
"""Infills transparent areas of an image using the PatchMatch algorithm"""
197197

198198
image: ImageField = InputField(description="The image to infill")
199-
downscale: Optional[float] = InputField(
200-
default=2.0, gt=0, description="Run patchmatch on downscaled image to speedup infill"
201-
)
202-
resample_mode: Optional[PIL_RESAMPLING_MODES] = InputField(default="bicubic", description="The resampling mode")
199+
downscale: float = InputField(default=2.0, gt=0, description="Run patchmatch on downscaled image to speedup infill")
200+
resample_mode: PIL_RESAMPLING_MODES = InputField(default="bicubic", description="The resampling mode")
203201

204202
def invoke(self, context: InvocationContext) -> ImageOutput:
205203
image = context.services.images.get_pil_image(self.image.image_name).convert("RGBA")

invokeai/backend/install/invokeai_configure.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,19 @@ def download_realesrgan():
290290
download_with_progress_bar(model["url"], config.models_path / model["dest"], model["description"])
291291

292292

293+
# ---------------------------------------------
294+
def download_lama():
295+
logger.info("Installing lama infill model")
296+
download_with_progress_bar(
297+
'https://github.com/Sanster/models/releases/download/add_big_lama/big-lama.pt',
298+
config.models_path / 'core/misc/lama/lama.pt',
299+
'lama infill model'
300+
)
301+
293302
# ---------------------------------------------
294303
def download_support_models():
295304
download_realesrgan()
305+
download_lama()
296306
download_conversion_models()
297307

298308

invokeai/frontend/web/src/features/nodes/util/graphBuilders/addSDXLRefinerToGraph.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export const addSDXLRefinerToGraph = (
4747
const { seamlessXAxis, seamlessYAxis, vaePrecision } = state.generation;
4848
const { boundingBoxScaleMethod } = state.canvas;
4949

50+
const fp32 = vaePrecision === 'fp32';
51+
5052
const isUsingScaledDimensions = ['auto', 'manual'].includes(
5153
boundingBoxScaleMethod
5254
);
@@ -232,7 +234,7 @@ export const addSDXLRefinerToGraph = (
232234
type: 'create_denoise_mask',
233235
id: SDXL_REFINER_INPAINT_CREATE_MASK,
234236
is_intermediate: true,
235-
fp32: vaePrecision === 'fp32' ? true : false,
237+
fp32,
236238
};
237239

238240
if (isUsingScaledDimensions) {

invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasImageToImageGraph.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export const buildCanvasImageToImageGraph = (
5959
shouldAutoSave,
6060
} = state.canvas;
6161

62+
const fp32 = vaePrecision === 'fp32';
63+
6264
const isUsingScaledDimensions = ['auto', 'manual'].includes(
6365
boundingBoxScaleMethod
6466
);
@@ -245,7 +247,7 @@ export const buildCanvasImageToImageGraph = (
245247
id: LATENTS_TO_IMAGE,
246248
type: 'l2i',
247249
is_intermediate: true,
248-
fp32: vaePrecision === 'fp32' ? true : false,
250+
fp32,
249251
};
250252
graph.nodes[CANVAS_OUTPUT] = {
251253
id: CANVAS_OUTPUT,
@@ -292,7 +294,7 @@ export const buildCanvasImageToImageGraph = (
292294
type: 'l2i',
293295
id: CANVAS_OUTPUT,
294296
is_intermediate: !shouldAutoSave,
295-
fp32: vaePrecision === 'fp32' ? true : false,
297+
fp32,
296298
};
297299

298300
(graph.nodes[IMAGE_TO_LATENTS] as ImageToLatentsInvocation).image =

invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ export const buildCanvasInpaintGraph = (
9393
shouldAutoSave,
9494
} = state.canvas;
9595

96+
const fp32 = vaePrecision === 'fp32';
97+
9698
const isUsingScaledDimensions = ['auto', 'manual'].includes(
9799
boundingBoxScaleMethod
98100
);
@@ -141,7 +143,7 @@ export const buildCanvasInpaintGraph = (
141143
type: 'i2l',
142144
id: INPAINT_IMAGE,
143145
is_intermediate: true,
144-
fp32: vaePrecision === 'fp32' ? true : false,
146+
fp32,
145147
},
146148
[NOISE]: {
147149
type: 'noise',
@@ -153,7 +155,7 @@ export const buildCanvasInpaintGraph = (
153155
type: 'create_denoise_mask',
154156
id: INPAINT_CREATE_MASK,
155157
is_intermediate: true,
156-
fp32: vaePrecision === 'fp32' ? true : false,
158+
fp32,
157159
},
158160
[DENOISE_LATENTS]: {
159161
type: 'denoise_latents',
@@ -191,7 +193,7 @@ export const buildCanvasInpaintGraph = (
191193
type: 'l2i',
192194
id: LATENTS_TO_IMAGE,
193195
is_intermediate: true,
194-
fp32: vaePrecision === 'fp32' ? true : false,
196+
fp32,
195197
},
196198
[CANVAS_OUTPUT]: {
197199
type: 'color_correct',
@@ -596,7 +598,7 @@ export const buildCanvasInpaintGraph = (
596598
type: 'create_denoise_mask',
597599
id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
598600
is_intermediate: true,
599-
fp32: vaePrecision === 'fp32' ? true : false,
601+
fp32,
600602
};
601603

602604
// Handle Image Input For Mask Creation

invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasOutpaintGraph.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ export const buildCanvasOutpaintGraph = (
9797
shouldAutoSave,
9898
} = state.canvas;
9999

100+
const fp32 = vaePrecision === 'fp32';
101+
100102
const isUsingScaledDimensions = ['auto', 'manual'].includes(
101103
boundingBoxScaleMethod
102104
);
@@ -150,7 +152,7 @@ export const buildCanvasOutpaintGraph = (
150152
type: 'i2l',
151153
id: INPAINT_IMAGE,
152154
is_intermediate: true,
153-
fp32: vaePrecision === 'fp32' ? true : false,
155+
fp32,
154156
},
155157
[NOISE]: {
156158
type: 'noise',
@@ -162,7 +164,7 @@ export const buildCanvasOutpaintGraph = (
162164
type: 'create_denoise_mask',
163165
id: INPAINT_CREATE_MASK,
164166
is_intermediate: true,
165-
fp32: vaePrecision === 'fp32' ? true : false,
167+
fp32,
166168
},
167169
[DENOISE_LATENTS]: {
168170
type: 'denoise_latents',
@@ -200,7 +202,7 @@ export const buildCanvasOutpaintGraph = (
200202
type: 'l2i',
201203
id: LATENTS_TO_IMAGE,
202204
is_intermediate: true,
203-
fp32: vaePrecision === 'fp32' ? true : false,
205+
fp32,
204206
},
205207
[CANVAS_OUTPUT]: {
206208
type: 'color_correct',
@@ -698,7 +700,7 @@ export const buildCanvasOutpaintGraph = (
698700
type: 'create_denoise_mask',
699701
id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
700702
is_intermediate: true,
701-
fp32: vaePrecision === 'fp32' ? true : false,
703+
fp32,
702704
};
703705

704706
// Handle Image Input For Mask Creation

invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasSDXLImageToImageGraph.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ export const buildCanvasSDXLImageToImageGraph = (
6767
shouldAutoSave,
6868
} = state.canvas;
6969

70+
const fp32 = vaePrecision === 'fp32';
71+
7072
const isUsingScaledDimensions = ['auto', 'manual'].includes(
7173
boundingBoxScaleMethod
7274
);
@@ -133,7 +135,7 @@ export const buildCanvasSDXLImageToImageGraph = (
133135
type: 'i2l',
134136
id: IMAGE_TO_LATENTS,
135137
is_intermediate: true,
136-
fp32: vaePrecision === 'fp32' ? true : false,
138+
fp32,
137139
},
138140
[SDXL_DENOISE_LATENTS]: {
139141
type: 'denoise_latents',
@@ -258,7 +260,7 @@ export const buildCanvasSDXLImageToImageGraph = (
258260
id: LATENTS_TO_IMAGE,
259261
type: 'l2i',
260262
is_intermediate: true,
261-
fp32: vaePrecision === 'fp32' ? true : false,
263+
fp32,
262264
};
263265
graph.nodes[CANVAS_OUTPUT] = {
264266
id: CANVAS_OUTPUT,
@@ -305,7 +307,7 @@ export const buildCanvasSDXLImageToImageGraph = (
305307
type: 'l2i',
306308
id: CANVAS_OUTPUT,
307309
is_intermediate: !shouldAutoSave,
308-
fp32: vaePrecision === 'fp32' ? true : false,
310+
fp32,
309311
};
310312

311313
(graph.nodes[IMAGE_TO_LATENTS] as ImageToLatentsInvocation).image =

invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasSDXLInpaintGraph.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ export const buildCanvasSDXLInpaintGraph = (
100100
shouldAutoSave,
101101
} = state.canvas;
102102

103+
const fp32 = vaePrecision === 'fp32';
104+
103105
const isUsingScaledDimensions = ['auto', 'manual'].includes(
104106
boundingBoxScaleMethod
105107
);
@@ -145,7 +147,7 @@ export const buildCanvasSDXLInpaintGraph = (
145147
type: 'i2l',
146148
id: INPAINT_IMAGE,
147149
is_intermediate: true,
148-
fp32: vaePrecision === 'fp32' ? true : false,
150+
fp32,
149151
},
150152
[NOISE]: {
151153
type: 'noise',
@@ -157,7 +159,7 @@ export const buildCanvasSDXLInpaintGraph = (
157159
type: 'create_denoise_mask',
158160
id: INPAINT_CREATE_MASK,
159161
is_intermediate: true,
160-
fp32: vaePrecision === 'fp32' ? true : false,
162+
fp32,
161163
},
162164
[SDXL_DENOISE_LATENTS]: {
163165
type: 'denoise_latents',
@@ -197,7 +199,7 @@ export const buildCanvasSDXLInpaintGraph = (
197199
type: 'l2i',
198200
id: LATENTS_TO_IMAGE,
199201
is_intermediate: true,
200-
fp32: vaePrecision === 'fp32' ? true : false,
202+
fp32,
201203
},
202204
[CANVAS_OUTPUT]: {
203205
type: 'color_correct',
@@ -611,7 +613,7 @@ export const buildCanvasSDXLInpaintGraph = (
611613
type: 'create_denoise_mask',
612614
id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
613615
is_intermediate: true,
614-
fp32: vaePrecision === 'fp32' ? true : false,
616+
fp32,
615617
};
616618

617619
// Handle Image Input For Mask Creation

invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasSDXLOutpaintGraph.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ export const buildCanvasSDXLOutpaintGraph = (
104104
shouldAutoSave,
105105
} = state.canvas;
106106

107+
const fp32 = vaePrecision === 'fp32';
108+
107109
const isUsingScaledDimensions = ['auto', 'manual'].includes(
108110
boundingBoxScaleMethod
109111
);
@@ -154,7 +156,7 @@ export const buildCanvasSDXLOutpaintGraph = (
154156
type: 'i2l',
155157
id: INPAINT_IMAGE,
156158
is_intermediate: true,
157-
fp32: vaePrecision === 'fp32' ? true : false,
159+
fp32,
158160
},
159161
[NOISE]: {
160162
type: 'noise',
@@ -166,7 +168,7 @@ export const buildCanvasSDXLOutpaintGraph = (
166168
type: 'create_denoise_mask',
167169
id: INPAINT_CREATE_MASK,
168170
is_intermediate: true,
169-
fp32: vaePrecision === 'fp32' ? true : false,
171+
fp32,
170172
},
171173
[SDXL_DENOISE_LATENTS]: {
172174
type: 'denoise_latents',
@@ -206,7 +208,7 @@ export const buildCanvasSDXLOutpaintGraph = (
206208
type: 'l2i',
207209
id: LATENTS_TO_IMAGE,
208210
is_intermediate: true,
209-
fp32: vaePrecision === 'fp32' ? true : false,
211+
fp32,
210212
},
211213
[CANVAS_OUTPUT]: {
212214
type: 'color_correct',
@@ -714,7 +716,7 @@ export const buildCanvasSDXLOutpaintGraph = (
714716
type: 'create_denoise_mask',
715717
id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
716718
is_intermediate: true,
717-
fp32: vaePrecision === 'fp32' ? true : false,
719+
fp32,
718720
};
719721

720722
// Handle Image Input For Mask Creation

invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasSDXLTextToImageGraph.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export const buildCanvasSDXLTextToImageGraph = (
6161
shouldAutoSave,
6262
} = state.canvas;
6363

64+
const fp32 = vaePrecision === 'fp32';
65+
6466
const isUsingScaledDimensions = ['auto', 'manual'].includes(
6567
boundingBoxScaleMethod
6668
);
@@ -252,7 +254,7 @@ export const buildCanvasSDXLTextToImageGraph = (
252254
id: LATENTS_TO_IMAGE,
253255
type: isUsingOnnxModel ? 'l2i_onnx' : 'l2i',
254256
is_intermediate: true,
255-
fp32: vaePrecision === 'fp32' ? true : false,
257+
fp32,
256258
};
257259

258260
graph.nodes[CANVAS_OUTPUT] = {
@@ -290,7 +292,7 @@ export const buildCanvasSDXLTextToImageGraph = (
290292
type: isUsingOnnxModel ? 'l2i_onnx' : 'l2i',
291293
id: CANVAS_OUTPUT,
292294
is_intermediate: !shouldAutoSave,
293-
fp32: vaePrecision === 'fp32' ? true : false,
295+
fp32,
294296
};
295297

296298
graph.edges.push({

0 commit comments

Comments
 (0)