diff --git a/README.md b/README.md index 25495e5..6bdaf28 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,14 @@ ```go type User struct { - ID int `json:"id"` - Name string `json:"name"` - Email string `json:"email"` - Password string `json:"password"` - CreatedAt string `json:"created_at"` - UpdatedAt string `json:"updated_at"` + ID int `json:"id" gorm:"primary_key"` + Name string `json:"name"` + Email string `json:"email" gorm:"unique;not null"` + Password string `json:"-"` + Slat string `json:"-"` + Admin bool `json:"admin"` + CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` + UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"` } ``` @@ -24,8 +26,12 @@ type User struct { ```go type Session struct { - ID string `json:"ID"` - UserID int `json:"user_id"` + ID string `json:"id" gorm:"primary_key"` + IP string `json:"ip"` + UserID int `json:"user_id"` + UserAgent string `json:"user_agent"` + CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` + UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"` } ``` @@ -40,8 +46,16 @@ type Session struct { ```go type Dataset struct { - Images []string `json:"images"` + ID int `json:"id" gorm:"primary_key"` + Name string `json:"name"` + Info string `json:"info"` + Images ImageList `json:"images"` + UserID int `json:"user_id"` + CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` + UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"` } + +type ImageList []string // image URL ``` - [x] GET [/api/datasets](/api/datasets) 數據集列表 @@ -55,10 +69,10 @@ type Dataset struct { ```go type Tag struct { - ID int `json:"id"` - Name string `json:"name"` - CreatedAt string `json:"created_at"` - UpdatedAt string `json:"updated_at"` + ID int `json:"id" gorm:"primary_key"` + Name string `json:"name"` + CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` + UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"` } ``` @@ -73,19 +87,23 @@ type Tag struct { ```go type Model struct { - ID int `json:"id"` - Name string `json:"name"` - Type string `json:"type"` // (lora|ckp|hyper|ti) - TriggerWords string `json:"trigger_words"` // 觸發詞 - BaseModel string `json:"base_model"` // (SD1.5|SD2) - ModelPath string `json:"model_path"` // 模型路徑 - Status string `json:"status"` // (initial|ready|waiting|running|success|error) - Progress int `json:"progress"` // (0-100) - Image string `json:"image"` // 封面圖片實際地址 - Tags string `json:"tags"` - CreatedAt string `json:"created_at"` - UpdatedAt string `json:"updated_at"` - UserID int `json:"user_id"` + ID int `json:"id" gorm:"primary_key"` + Name string `json:"name"` + Type string `json:"type"` // (lora|ckp|hyper|ti) + TriggerWords string `json:"trigger_words"` // 觸發詞 + BaseModel string `json:"base_model"` // (SD1.5|SD2) + ModelPath string `json:"model_path"` // 模型路徑 + Status string `json:"status" default:"initial"` // (initial|ready|waiting|running|success|error) + Progress int `json:"progress"` // (0-100) + Image string `json:"image"` // 封面圖片實際地址 + Hash string `json:"hash"` // 模型哈希值 + Epochs int `json:"epochs"` // 訓練步數 + Tags TagList `json:"tags"` + UserID int `json:"user_id"` + DatasetID int `json:"dataset_id"` + ServerID int `json:"server_id"` + CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` + UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"` } ``` @@ -103,20 +121,20 @@ type Model struct { ```go type Image struct { - ID int `json:"id"` - 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"` // (1~500) - GuidanceScale float32 `json:"guidance_scale"` // (1~20) - Scheduler string `json:"scheduler"` // (DDIM|K_EULER|DPMSolverMultistep|K_EULER_ANCESTRAL|PNDM|KLMS) - Seed int `json:"seed"` // 隨機數種子 - FromImage string `json:"from_image"` // 圖片地址(以圖繪圖) - CreatedAt string `json:"created_at"` - UpdatedAt string `json:"updated_at"` - UserID int `json:"user_id"` + 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"` } ``` @@ -129,14 +147,14 @@ type Image struct { ```go type Task struct { - ID int `json:"id"` - Name string `json:"name"` - Type string `json:"type"` // 任務類型(訓練|推理) - Status string `json:"status"` // 任務狀態(initial|ready|waiting|running|success|error) - Progress int `json:"progress"` // 任務進度(0-100) - CreatedAt string `json:"created_at"` - UpdatedAt string `json:"updated_at"` - UserID int `json:"user_id"` + ID int `json:"id" gorm:"primary_key"` + Name string `json:"name"` + Type string `json:"type"` // 任務類型(訓練|推理) + Status string `json:"status"` // (initial|ready|waiting|running|success|error) + Progress int `json:"progress"` // (0-100) + UserID int `json:"user_id"` + CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` + UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"` } ``` @@ -161,7 +179,13 @@ type Param struct { ```go type Account struct { - // 同 user + ID int `json:"id"` + Name string `json:"name"` + Email string `json:"email"` + Admin bool `json:"admin"` + SessionID string `json:"session_id"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` } ``` @@ -173,7 +197,17 @@ type Account struct { ```go type Server struct { - IP string `json:"ip"` + ID int `json:"id" gorm:"primary_key"` + Name string `json:"name"` + Type string `json:"type"` // (訓練|推理) + IP string `json:"ip"` + Port int `json:"port"` + Status string `json:"status"` // (異常|初始化|閒置|就緒|工作中|關閉中) + UserName string `json:"username"` + Password string `json:"password"` + Models []map[string]interface{} `json:"models" gorm:"-"` // 數據庫不必保存 + CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` + UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"` } ```