Skip to content

Commit c3f7bcc

Browse files
committed
Init
1 parent 6f760fc commit c3f7bcc

File tree

7 files changed

+296
-175
lines changed

7 files changed

+296
-175
lines changed

main.go

+57-40
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
package main
22

33
import (
4-
"io"
54
"os"
65

76
"github.com/ring-c/go-web-diff/pkg/opts"
87
"github.com/ring-c/go-web-diff/pkg/sd"
98
)
109

1110
func main() {
12-
1311
options := sd.DefaultOptions
1412
options.GpuEnable = true
1513
options.Wtype = opts.F16
1614
options.Schedule = opts.KARRAS
15+
options.Debug = true
1716

1817
model, err := sd.NewModel(options)
1918
if err != nil {
@@ -30,56 +29,74 @@ func main() {
3029
return
3130
}
3231

33-
filenames := []string{
34-
"./output/0.png",
32+
// println(model.GetSystemInfo())
33+
34+
err = generate(model)
35+
if err != nil {
36+
println(err.Error())
37+
return
3538
}
3639

37-
var writers []io.Writer
38-
for _, filename := range filenames {
39-
var file *os.File
40-
file, err = os.Create(filename)
41-
if err != nil {
42-
println(err.Error())
43-
return
44-
}
45-
46-
writers = append(writers, file)
47-
defer func() {
48-
_ = file.Close()
49-
}()
40+
// err = upscale(model)
41+
// if err != nil {
42+
// println(err.Error())
43+
// return
44+
// }
45+
}
46+
47+
func generate(model *sd.Model) (err error) {
48+
var file *os.File
49+
file, err = os.Create("./output/0.png")
50+
if err != nil {
51+
println(err.Error())
52+
return
5053
}
5154

55+
defer func() {
56+
_ = file.Close()
57+
}()
58+
5259
var params = sd.DefaultFullParams
5360
params.Width = 1024
5461
params.Height = 1024
5562
params.CfgScale = 2
56-
params.SampleSteps = 32
63+
params.SampleSteps = 4
5764
params.SampleMethod = opts.EULER_A
58-
params.BatchCount = len(writers)
65+
params.Seed = 4242
5966

60-
err = model.Predict("1wolf, forest, full body", params, writers)
67+
err = model.Predict("1girl, indoors, full body", params, file)
68+
if err != nil {
69+
return
70+
}
71+
72+
return
73+
}
74+
75+
/*
76+
func upscale(model *sd.Model) (err error) {
77+
fileRead, err := os.Open("./output/0.png")
78+
if err != nil {
79+
return
80+
}
81+
82+
defer func() {
83+
_ = fileRead.Close()
84+
}()
85+
86+
fileWrite, err := os.Create("./output/1.png")
87+
if err != nil {
88+
return
89+
}
90+
91+
defer func() {
92+
_ = fileWrite.Close()
93+
}()
94+
95+
err = model.UpscaleImage(fileRead, "/media/ed/files/sd/models/ESRGAN/RealESRGAN_x4plus_anime_6B.pth", 2, fileWrite)
6196
if err != nil {
62-
println(err.Error())
6397
return
6498
}
6599
66-
/*
67-
fileRead, err := os.Open("./output/1.png")
68-
if err != nil {
69-
println(err.Error())
70-
return
71-
}
72-
73-
fileWrite, err := os.Create("./output/2.png")
74-
if err != nil {
75-
println(err.Error())
76-
return
77-
}
78-
79-
err = model.UpscaleImage(fileRead, "/media/ed/files/sd/models/ESRGAN/RealESRGAN_x4plus_anime_6B.pth", 2, fileWrite)
80-
if err != nil {
81-
println(err.Error())
82-
return
83-
}
84-
*/
100+
return
85101
}
102+
*/

0 commit comments

Comments
 (0)