Files
ai/models/Image.go
2023-05-27 16:40:04 +08:00

40 lines
1.4 KiB
Go

package models
import (
"database/sql/driver"
"encoding/json"
"main/configs"
"time"
)
type Image struct {
ID int `json:"id" gorm:"primary_key"`
Name string `json:"name"`
Width int `json:"width"`
Height int `json:"height"`
Prompt string `json:"prompt"`
NegativePrompt string `json:"negative_prompt"`
NumInferenceSteps int `json:"num_inference_steps"` // Number of inference steps (minimum: 1; maximum: 500)
GuidanceScale float32 `json:"guidance_scale"` // Scale for classifier-free guidance (minimum: 1; maximum: 20)
Scheduler string `json:"scheduler"` // (DDIM|K_EULER|DPMSolverMultistep|K_EULER_ANCESTRAL|PNDM|KLMS)
Seed int `json:"seed"` // Random seed (minimum: 0; maximum: 2147483647)
FromImage string `json:"from_image"` // Image to start from
UserID int `json:"user_id"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
func init() {
configs.ORMDB().AutoMigrate(&Image{})
}
type ImageList []string
func (list *ImageList) Scan(value interface{}) error {
return json.Unmarshal(value.([]byte), list)
}
func (list ImageList) Value() (driver.Value, error) {
return json.Marshal(list)
}