补全默认参数
This commit is contained in:
		@@ -61,6 +61,8 @@ func init() {
 | 
			
		||||
			model.ModelPath = "data/models/" + file.Name()
 | 
			
		||||
			model.Type = "ckp"
 | 
			
		||||
			model.Status = "success"
 | 
			
		||||
			model.Progress = 100
 | 
			
		||||
			model.Tags = []string{"平台模型"}
 | 
			
		||||
 | 
			
		||||
			log.Println("模型不存在, 添加到数据库:", file.Name())
 | 
			
		||||
			configs.ORMDB().Create(&model)
 | 
			
		||||
@@ -266,12 +268,30 @@ func ModelItemPatch(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		// 如果狀態被改變爲 ready, 將模型發送到訓練隊列
 | 
			
		||||
		if model.Status == "ready" {
 | 
			
		||||
			model.Status = "training"
 | 
			
		||||
			go model.Train()
 | 
			
		||||
			//go model.Train()
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if model_new.Image != "" && model_new.Image != model.Image {
 | 
			
		||||
		model.Image = model_new.Image
 | 
			
		||||
	}
 | 
			
		||||
	if model_new.TriggerWords != "" && model_new.TriggerWords != model.TriggerWords {
 | 
			
		||||
		model.TriggerWords = model_new.TriggerWords
 | 
			
		||||
	}
 | 
			
		||||
	if model_new.BaseModel != "" && model_new.BaseModel != model.BaseModel {
 | 
			
		||||
		model.BaseModel = model_new.BaseModel
 | 
			
		||||
	}
 | 
			
		||||
	if model_new.ModelPath != "" && model_new.ModelPath != model.ModelPath {
 | 
			
		||||
		model.ModelPath = model_new.ModelPath
 | 
			
		||||
	}
 | 
			
		||||
	if model_new.Hash != "" && model_new.Hash != model.Hash {
 | 
			
		||||
		model.Hash = model_new.Hash
 | 
			
		||||
	}
 | 
			
		||||
	if model_new.Epochs != 0 && model_new.Epochs != model.Epochs {
 | 
			
		||||
		model.Epochs = model_new.Epochs
 | 
			
		||||
	}
 | 
			
		||||
	if model_new.Progress != 0 && model_new.Progress != model.Progress {
 | 
			
		||||
		model.Progress = model_new.Progress
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 執行更新
 | 
			
		||||
	if err := configs.ORMDB().Save(&model).Error; err != nil {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user