Skip to content

Commit 1c7ea57

Browse files
feat (ui, generation): High Resolution Fix- added automatic resolution toggle and replaced latent upscale with two improved methods (#4905)
* working * added selector for method * refactoring graph * added ersgan method * fixing yarn build * add tooltips * a conjuction * rephrase * removed manual sliders, set HRF to calculate dimensions automatically to match 512^2 pixels * working * working * working * fixed tooltip * add hrf to use all parameters * adding hrf method to parameters * working on parameter recall * working on parameter recall * cleaning * fix(ui): fix unnecessary casts in addHrfToGraph * chore(ui): use camelCase in addHrfToGraph * fix(ui): do not add HRF metadata unless HRF is added to graph * fix(ui): remove unused imports in addHrfToGraph * feat(ui): do not hide HRF params when disabled, only disable them * fix(ui): remove unused vars in addHrfToGraph * feat(ui): default HRF str to 0.35, method ESRGAN * fix(ui): use isValidBoolean to check hrfEnabled param * fix(nodes): update CoreMetadataInvocation fields for HRF * feat(ui): set hrf strength default to 0.45 * fix(ui): set default hrf strength in configSlice * feat(ui): use translations for HRF features --------- Co-authored-by: psychedelicious <[email protected]>
1 parent 9ccfa34 commit 1c7ea57

File tree

19 files changed

+573
-349
lines changed

19 files changed

+573
-349
lines changed

invokeai/app/invocations/metadata.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,14 @@ class CoreMetadataInvocation(BaseInvocation):
160160
)
161161

162162
# High resolution fix metadata.
163-
hrf_width: Optional[int] = InputField(
163+
hrf_enabled: Optional[float] = InputField(
164164
default=None,
165-
description="The high resolution fix height and width multipler.",
165+
description="Whether or not high resolution fix was enabled.",
166166
)
167-
hrf_height: Optional[int] = InputField(
167+
# TODO: should this be stricter or do we just let the UI handle it?
168+
hrf_method: Optional[str] = InputField(
168169
default=None,
169-
description="The high resolution fix height and width multipler.",
170+
description="The high resolution fix upscale method.",
170171
)
171172
hrf_strength: Optional[float] = InputField(
172173
default=None,

invokeai/frontend/web/public/locales/en.json

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,19 @@
221221
"resetIPAdapterImage": "Reset IP Adapter Image",
222222
"ipAdapterImageFallback": "No IP Adapter Image Selected"
223223
},
224+
"hrf": {
225+
"hrf": "High Resolution Fix",
226+
"enableHrf": "Enable High Resolution Fix",
227+
"enableHrfTooltip": "Generate with a lower initial resolution, upscale to the base resolution, then run Image-to-Image.",
228+
"upscaleMethod": "Upscale Method",
229+
"hrfStrength": "High Resolution Fix Strength",
230+
"strengthTooltip": "Lower values result in fewer details, which may reduce potential artifacts.",
231+
"metadata": {
232+
"enabled": "High Resolution Fix Enabled",
233+
"strength": "High Resolution Fix Strength",
234+
"method": "High Resolution Fix Method"
235+
}
236+
},
224237
"embedding": {
225238
"addEmbedding": "Add Embedding",
226239
"incompatibleModel": "Incompatible base model:",
@@ -1258,15 +1271,11 @@
12581271
},
12591272
"compositingBlur": {
12601273
"heading": "Blur",
1261-
"paragraphs": [
1262-
"The blur radius of the mask."
1263-
]
1274+
"paragraphs": ["The blur radius of the mask."]
12641275
},
12651276
"compositingBlurMethod": {
12661277
"heading": "Blur Method",
1267-
"paragraphs": [
1268-
"The method of blur applied to the masked area."
1269-
]
1278+
"paragraphs": ["The method of blur applied to the masked area."]
12701279
},
12711280
"compositingCoherencePass": {
12721281
"heading": "Coherence Pass",
@@ -1276,9 +1285,7 @@
12761285
},
12771286
"compositingCoherenceMode": {
12781287
"heading": "Mode",
1279-
"paragraphs": [
1280-
"The mode of the Coherence Pass."
1281-
]
1288+
"paragraphs": ["The mode of the Coherence Pass."]
12821289
},
12831290
"compositingCoherenceSteps": {
12841291
"heading": "Steps",
@@ -1296,9 +1303,7 @@
12961303
},
12971304
"compositingMaskAdjustments": {
12981305
"heading": "Mask Adjustments",
1299-
"paragraphs": [
1300-
"Adjust the mask."
1301-
]
1306+
"paragraphs": ["Adjust the mask."]
13021307
},
13031308
"controlNetBeginEnd": {
13041309
"heading": "Begin / End Step Percentage",
@@ -1356,9 +1361,7 @@
13561361
},
13571362
"infillMethod": {
13581363
"heading": "Infill Method",
1359-
"paragraphs": [
1360-
"Method to infill the selected area."
1361-
]
1364+
"paragraphs": ["Method to infill the selected area."]
13621365
},
13631366
"lora": {
13641367
"heading": "LoRA Weight",

invokeai/frontend/web/src/features/gallery/components/ImageMetadataViewer/ImageMetadataActions.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ const ImageMetadataActions = (props: Props) => {
3535
recallWidth,
3636
recallHeight,
3737
recallStrength,
38+
recallHrfEnabled,
39+
recallHrfStrength,
40+
recallHrfMethod,
3841
recallLoRA,
3942
recallControlNet,
4043
recallIPAdapter,
@@ -81,6 +84,18 @@ const ImageMetadataActions = (props: Props) => {
8184
recallStrength(metadata?.strength);
8285
}, [metadata?.strength, recallStrength]);
8386

87+
const handleRecallHrfEnabled = useCallback(() => {
88+
recallHrfEnabled(metadata?.hrf_enabled);
89+
}, [metadata?.hrf_enabled, recallHrfEnabled]);
90+
91+
const handleRecallHrfStrength = useCallback(() => {
92+
recallHrfStrength(metadata?.hrf_strength);
93+
}, [metadata?.hrf_strength, recallHrfStrength]);
94+
95+
const handleRecallHrfMethod = useCallback(() => {
96+
recallHrfMethod(metadata?.hrf_method);
97+
}, [metadata?.hrf_method, recallHrfMethod]);
98+
8499
const handleRecallLoRA = useCallback(
85100
(lora: LoRAMetadataItem) => {
86101
recallLoRA(lora);
@@ -225,6 +240,27 @@ const ImageMetadataActions = (props: Props) => {
225240
onClick={handleRecallStrength}
226241
/>
227242
)}
243+
{metadata.hrf_enabled && (
244+
<ImageMetadataItem
245+
label={t('hrf.metadata.enabled')}
246+
value={metadata.hrf_enabled}
247+
onClick={handleRecallHrfEnabled}
248+
/>
249+
)}
250+
{metadata.hrf_enabled && metadata.hrf_strength && (
251+
<ImageMetadataItem
252+
label={t('hrf.metadata.strength')}
253+
value={metadata.hrf_strength}
254+
onClick={handleRecallHrfStrength}
255+
/>
256+
)}
257+
{metadata.hrf_enabled && metadata.hrf_method && (
258+
<ImageMetadataItem
259+
label={t('hrf.metadata.method')}
260+
value={metadata.hrf_method}
261+
onClick={handleRecallHrfMethod}
262+
/>
263+
)}
228264
{metadata.loras &&
229265
metadata.loras.map((lora, index) => {
230266
if (isValidLoRAModel(lora.lora)) {

invokeai/frontend/web/src/features/nodes/types/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,9 @@ export const zCoreMetadata = z
14241424
loras: z.array(zLoRAMetadataItem).nullish().catch(null),
14251425
vae: zVaeModelField.nullish().catch(null),
14261426
strength: z.number().nullish().catch(null),
1427+
hrf_enabled: z.boolean().nullish().catch(null),
1428+
hrf_strength: z.number().nullish().catch(null),
1429+
hrf_method: z.string().nullish().catch(null),
14271430
init_image: z.string().nullish().catch(null),
14281431
positive_style_prompt: z.string().nullish().catch(null),
14291432
negative_style_prompt: z.string().nullish().catch(null),

0 commit comments

Comments
 (0)