生成多张

This commit is contained in:
2023-06-22 04:24:49 +08:00
parent 5cfa43dc3a
commit b8f871d676
3 changed files with 44 additions and 22 deletions

View File

@@ -41,6 +41,29 @@ type Image struct {
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
//// 参数校验
//func (img *Image) ParameterCheck() (err error) {
// if img.NumInferenceSteps <= 0 {
// img.NumInferenceSteps = 20
// }
// if img.NumInferenceSteps > 500 {
// img.NumInferenceSteps = 500
// }
// if img.GuidanceScale <= 0 {
// img.GuidanceScale = 1
// }
// if img.GuidanceScale > 20 {
// img.GuidanceScale = 20
// }
// if img.Scheduler == "" {
// img.Scheduler = "DDIM"
// }
// if img.Seed == "" {
// img.Seed = "0"
// }
// return
//}
// 将图片输出为指定尺寸的 webp 格式(默认使用 Lanczos 缩放算法)
func (img *Image) ToWebP(width int, height int, fit string) ([]byte, error) {
// 從絕對路徑讀原始圖片

View File

@@ -67,8 +67,6 @@ func init() {
}
func (model *Model) Inference(image_list []Image, callback func(Image)) {
log.Println(image_list)
// 模型未部署到推理機
if model.ServerID == "" {
//log.Println("模型未部署到推理機, 开始部署模型")
@@ -87,6 +85,7 @@ func (model *Model) Inference(image_list []Image, callback func(Image)) {
// 执行生成任务
if model.Image == "" {
// 发送的参数
var data = struct {
//EnableHr bool `json:"enable_hr"`
//DenoisingStrength int `json:"denoising_strength"`
@@ -109,8 +108,8 @@ func (model *Model) Inference(image_list []Image, callback func(Image)) {
//SeedResizeFromW int `json:"seed_resize_from_w"`
//SamplerName string `json:"sampler_name"`
//BatchSize int `json:"batch_size"`
//NIter int `json:"n_iter"`
//Steps int `json:"steps"`
NIter int `json:"n_iter"`
Steps int `json:"steps"`
//CfgScale int `json:"cfg_scale"`
//Width int `json:"width"`
//Height int `json:"height"`
@@ -146,7 +145,7 @@ func (model *Model) Inference(image_list []Image, callback func(Image)) {
//HrSamplerName: "",
//HrPrompt: "",
//HrNegativePrompt: "",
Prompt: "miao~",
Prompt: image_list[0].Prompt,
//Styles: []string{},
//Seed: -1,
//Subseed: -1,
@@ -155,8 +154,8 @@ func (model *Model) Inference(image_list []Image, callback func(Image)) {
//SeedResizeFromW: -1,
//SamplerName: "beamsearch",
//BatchSize: 1,
//NIter: 1,
//Steps: 50,
NIter: len(image_list),
Steps: 50,
//CfgScale: 7,
//Width: 512,
//Height: 512,