ws更新触发
This commit is contained in:
@@ -66,7 +66,7 @@ func init() {
|
||||
//}()
|
||||
}
|
||||
|
||||
func (model *Model) Inference(image_list []Image, callback func()) {
|
||||
func (model *Model) Inference(image_list []Image, callback func(Image)) {
|
||||
log.Println(image_list)
|
||||
|
||||
// 模型未部署到推理機
|
||||
@@ -188,17 +188,22 @@ func (model *Model) Inference(image_list []Image, callback func()) {
|
||||
if err := goreq.Post(url).SetJsonBody(data).Do().BindJSON(&rest); err != nil {
|
||||
log.Println("API 查询失败:", err)
|
||||
}
|
||||
log.Println("API 查询成功:", rest)
|
||||
for _, img := range rest.Images {
|
||||
log.Println("保存图片:", img)
|
||||
// 将base64编码的图片保存到本地webp
|
||||
for index, img := range rest.Images {
|
||||
var filename = fmt.Sprintf("%x", md5.Sum([]byte(img)))
|
||||
log.Println("保存图片:", filename)
|
||||
if err := SaveBase64Image(img, "data/images/"+filename+".webp"); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
image_list[index].Name = filename
|
||||
image_list[index].Path = "data/images/" + filename + ".webp"
|
||||
image_list[index].Hash = filename
|
||||
image_list[index].Type = "image/webp"
|
||||
image_list[index].Width = 512
|
||||
image_list[index].Height = 512
|
||||
image_list[index].Format = "webp"
|
||||
callback(image_list[index])
|
||||
}
|
||||
}
|
||||
callback()
|
||||
return
|
||||
}
|
||||
log.Println("模型未部署到推理機, 取消推理模型")
|
||||
|
Reference in New Issue
Block a user