@@ -2,7 +2,6 @@ import type { RootState } from 'app/store/store';
2
2
import { fetchModelConfigWithTypeGuard } from 'features/metadata/util/modelFetchingHelpers' ;
3
3
import type { GraphType } from 'features/nodes/util/graph/generation/Graph' ;
4
4
import { Graph } from 'features/nodes/util/graph/generation/Graph' ;
5
- import type { ImageDTO } from 'services/api/types' ;
6
5
import { isNonRefinerMainModelConfig , isSpandrelImageToImageModelConfig } from 'services/api/types' ;
7
6
import { assert } from 'tsafe' ;
8
7
@@ -15,7 +14,6 @@ import {
15
14
NEGATIVE_CONDITIONING ,
16
15
NOISE ,
17
16
POSITIVE_CONDITIONING ,
18
- RESIZE ,
19
17
SDXL_MODEL_LOADER ,
20
18
SPANDREL ,
21
19
TILED_MULTI_DIFFUSION_DENOISE_LATENTS ,
@@ -26,27 +24,17 @@ import { addLoRAs } from './generation/addLoRAs';
26
24
import { addSDXLLoRas } from './generation/addSDXLLoRAs' ;
27
25
import { getBoardField , getSDXLStylePrompts } from './graphBuilderUtils' ;
28
26
29
- const UPSCALE_SCALE = 2 ;
30
-
31
- export const getOutputImageSize = ( initialImage : ImageDTO ) => {
32
- return {
33
- width : ( ( initialImage . width * UPSCALE_SCALE ) / 8 ) * 8 ,
34
- height : ( ( initialImage . height * UPSCALE_SCALE ) / 8 ) * 8 ,
35
- } ;
36
- } ;
37
-
38
27
export const buildMultidiffusionUpscsaleGraph = async ( state : RootState ) : Promise < GraphType > => {
39
28
const { model, cfgScale : cfg_scale , scheduler, steps, vaePrecision, seed, vae } = state . generation ;
40
29
const { positivePrompt, negativePrompt } = state . controlLayers . present ;
41
- const { upscaleModel, upscaleInitialImage, sharpness, structure, creativity, tileControlnetModel } = state . upscale ;
30
+ const { upscaleModel, upscaleInitialImage, sharpness, structure, creativity, tileControlnetModel, scale } =
31
+ state . upscale ;
42
32
43
33
assert ( model , 'No model found in state' ) ;
44
34
assert ( upscaleModel , 'No upscale model found in state' ) ;
45
35
assert ( upscaleInitialImage , 'No initial image found in state' ) ;
46
36
assert ( tileControlnetModel , 'Tile controlnet is required' ) ;
47
37
48
- const { width : outputWidth , height : outputHeight } = getOutputImageSize ( upscaleInitialImage ) ;
49
-
50
38
const g = new Graph ( ) ;
51
39
52
40
const unsharpMaskNode1 = g . addNode ( {
@@ -61,7 +49,8 @@ export const buildMultidiffusionUpscsaleGraph = async (state: RootState): Promis
61
49
id : SPANDREL ,
62
50
type : 'spandrel_image_to_image' ,
63
51
image_to_image_model : upscaleModel ,
64
- tile_size : 500 ,
52
+ fit_to_multiple_of_8 : true ,
53
+ scale,
65
54
} ) ;
66
55
67
56
g . addEdge ( unsharpMaskNode1 , 'image' , upscaleNode , 'image' ) ;
@@ -75,24 +64,14 @@ export const buildMultidiffusionUpscsaleGraph = async (state: RootState): Promis
75
64
76
65
g . addEdge ( upscaleNode , 'image' , unsharpMaskNode2 , 'image' ) ;
77
66
78
- const resizeNode = g . addNode ( {
79
- id : RESIZE ,
80
- type : 'img_resize' ,
81
- width : outputWidth ,
82
- height : outputHeight ,
83
- resample_mode : 'lanczos' ,
84
- } ) ;
85
-
86
- g . addEdge ( unsharpMaskNode2 , 'image' , resizeNode , 'image' ) ;
87
-
88
67
const noiseNode = g . addNode ( {
89
68
id : NOISE ,
90
69
type : 'noise' ,
91
70
seed,
92
71
} ) ;
93
72
94
- g . addEdge ( resizeNode , 'width' , noiseNode , 'width' ) ;
95
- g . addEdge ( resizeNode , 'height' , noiseNode , 'height' ) ;
73
+ g . addEdge ( unsharpMaskNode2 , 'width' , noiseNode , 'width' ) ;
74
+ g . addEdge ( unsharpMaskNode2 , 'height' , noiseNode , 'height' ) ;
96
75
97
76
const i2lNode = g . addNode ( {
98
77
id : IMAGE_TO_LATENTS ,
@@ -101,7 +80,7 @@ export const buildMultidiffusionUpscsaleGraph = async (state: RootState): Promis
101
80
tiled : true ,
102
81
} ) ;
103
82
104
- g . addEdge ( resizeNode , 'image' , i2lNode , 'image' ) ;
83
+ g . addEdge ( unsharpMaskNode2 , 'image' , i2lNode , 'image' ) ;
105
84
106
85
const l2iNode = g . addNode ( {
107
86
type : 'l2i' ,
@@ -160,8 +139,6 @@ export const buildMultidiffusionUpscsaleGraph = async (state: RootState): Promis
160
139
161
140
g . upsertMetadata ( {
162
141
cfg_scale,
163
- height : outputHeight ,
164
- width : outputWidth ,
165
142
positive_prompt : positivePrompt ,
166
143
negative_prompt : negativePrompt ,
167
144
positive_style_prompt : positiveStylePrompt ,
@@ -204,8 +181,6 @@ export const buildMultidiffusionUpscsaleGraph = async (state: RootState): Promis
204
181
205
182
g . upsertMetadata ( {
206
183
cfg_scale,
207
- height : outputHeight ,
208
- width : outputWidth ,
209
184
positive_prompt : positivePrompt ,
210
185
negative_prompt : negativePrompt ,
211
186
model : Graph . getModelMetadataField ( modelConfig ) ,
@@ -221,6 +196,8 @@ export const buildMultidiffusionUpscsaleGraph = async (state: RootState): Promis
221
196
}
222
197
223
198
g . setMetadataReceivingNode ( l2iNode ) ;
199
+ g . addEdgeToMetadata ( upscaleNode , 'width' , 'width' ) ;
200
+ g . addEdgeToMetadata ( upscaleNode , 'height' , 'height' ) ;
224
201
225
202
let vaeNode ;
226
203
if ( vae ) {
@@ -252,7 +229,7 @@ export const buildMultidiffusionUpscsaleGraph = async (state: RootState): Promis
252
229
end_step_percent : ( structure + 10 ) * 0.025 + 0.3 ,
253
230
} ) ;
254
231
255
- g . addEdge ( resizeNode , 'image' , controlnetNode1 , 'image' ) ;
232
+ g . addEdge ( unsharpMaskNode2 , 'image' , controlnetNode1 , 'image' ) ;
256
233
257
234
const controlnetNode2 = g . addNode ( {
258
235
id : 'controlnet_2' ,
@@ -265,7 +242,7 @@ export const buildMultidiffusionUpscsaleGraph = async (state: RootState): Promis
265
242
end_step_percent : 0.85 ,
266
243
} ) ;
267
244
268
- g . addEdge ( resizeNode , 'image' , controlnetNode2 , 'image' ) ;
245
+ g . addEdge ( unsharpMaskNode2 , 'image' , controlnetNode2 , 'image' ) ;
269
246
270
247
const collectNode = g . addNode ( {
271
248
id : CONTROL_NET_COLLECT ,
0 commit comments