-
Notifications
You must be signed in to change notification settings - Fork 1
/
ksampler.go
79 lines (64 loc) · 1.76 KB
/
ksampler.go
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
package comfywgo
import "fmt"
type KSamplerParams struct {
*Params
}
func NewKSamplerParams() KSamplerParams {
return KSamplerParams{NewParams("model", "positive", "negative", "latent_image")}
}
func (k KSamplerParams) Steps(steps int) KSamplerParams {
k.Inputs["steps"] = steps
return k
}
func (k KSamplerParams) Seed(seed int) KSamplerParams {
k.Inputs["seed"] = seed
return k
}
func (k KSamplerParams) CFG(cfg float32) KSamplerParams {
k.Inputs["cfg"] = cfg
return k
}
func (k KSamplerParams) Sampler(samplerName string) KSamplerParams {
k.Inputs["sampler_name"] = samplerName
return k
}
func (k KSamplerParams) Scheduler(scheduler string) KSamplerParams {
k.Inputs["scheduler"] = scheduler
return k
}
func (k KSamplerParams) Denoise(denoise float32) KSamplerParams {
k.Inputs["denoise"] = denoise
return k
}
func (k KSamplerParams) Model(model *Node) KSamplerParams {
k.Inputs["model"] = model.Output(Model)
return k
}
func (k KSamplerParams) Positive(positive *Node) KSamplerParams {
k.Inputs["positive"] = positive.Output(Conditioning)
return k
}
func (k KSamplerParams) Negative(negative *Node) KSamplerParams {
k.Inputs["negative"] = negative.Output(Conditioning)
return k
}
func (k KSamplerParams) Latent(latent *Node) KSamplerParams {
k.Inputs["latent_image"] = latent.Output(Latent)
return k
}
func (w *Workflow) KSampler(config KSamplerParams) *Node {
node := w.Node("KSampler").
WithInput("steps", 30).
WithInput("cfg", 8.0).
WithInput("sampler_name", "euler").
WithInput("scheduler", "kerras").
WithInput("denoise", 1.0).
InputMap(config.Inputs).
WithOutput(Latent, 0)
for _, k := range config.Required {
if _, ok := config.Inputs[k]; !ok {
node.Error(fmt.Errorf("%s is Required for %s", k, node.ClassType))
}
}
return node
}