-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiDiffusion.ts
116 lines (111 loc) · 3.05 KB
/
multiDiffusion.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { StoryPage } from "./types";
export function getRegion({
x = 0.0,
y = 0.0,
w = 1.0,
h = 1.0,
prompt,
negativePrompt = "",
blendMode = "Foreground",
featherRatio = 0.2,
seed = -1,
}: {
x?: number;
y?: number;
w?: number;
h?: number;
prompt: string;
negativePrompt?: string;
blendMode?: "Background" | "Foreground";
featherRatio?: number;
seed?: number;
}) {
return [
"True", // enable - bool,
x, // x -float,
y, // y - float,
w, // w - float,
h, // h - float
prompt, // prompt - str
negativePrompt, // neg_prompt - str
blendMode, // blend_mode - str
featherRatio, // feather_ratio - float
seed,
];
}
export function getMultiDiffusionScriptArgs({
width,
height,
storyPage,
useRegions,
}: {
width: number;
height: number;
storyPage: StoryPage;
useRegions: boolean;
}) {
if (useRegions) {
console.log("### Background Prompt: ", storyPage.background);
console.log("### Hero Prompt: ", storyPage.heroPrompt);
console.log("### Supporting Character Prompt: ", storyPage.supportPrompt);
}
return {
"Tiled Diffusion": {
// TODO: type this?
args: [
"True", // enabled - bool
"MultiDiffusion", // method - str ("Mixture of Diffusers" or "MultiDiffusion")
"False", // overwrite_size - bool
"False", // keep_input_size - bool
Number(width), // image_width - int
Number(height), // image_height - int
// Don't think these do anything while Region control is active.
96, // tile_width - int
96, // tile_height - int
48, // overlap - int
8, // tile_batch_size - int
"R-ESRGAN 4x+", // upscaler_name - str // "SwinIR_4x"
2, // scale_factor - float
null, // noise_inverse - bool
null, // noise_inverse_steps - int
null, // noise inverse_retouch - float
null, // noise_inverse_renoise_strength - float
null, // noise_inverse_renoise_kernel - int
"False", // control_tensor_cpu - bool
useRegions ? "True" : "False", // enable_bbox_control - bool
"False", // draw_background - bool
"False", // causual_layers - bool
// Background layer
...(useRegions
? [
...getRegion({
prompt: storyPage.background,
blendMode: "Background",
}),
// The protagonist is front and center of this.
...getRegion({
x: 0.0,
y: 0.1,
w: 0.6,
h: 0.9,
//featherRatio: 0.2,
prompt: storyPage.heroPrompt,
}),
// Other person/character
...getRegion({
x: 0.4,
y: 0.1,
w: 0.6,
h: 0.9,
//featherRatio: 0.3,
prompt: storyPage.supportPrompt,
}),
]
: []),
],
"Tiled VAE": {
args: ["True", "True", "True", "True", "False", 2048, 192],
},
},
};
}