Commit 308db6ac authored by brent's avatar brent

add async

parent 018f97ef
No preview for this file type
...@@ -67,3 +67,68 @@ llava-13b: ...@@ -67,3 +67,68 @@ llava-13b:
version: "b5f6212d032508382d61ff00469ddda3e32fd8a0e75dc39d8a4191bb742157fb" version: "b5f6212d032508382d61ff00469ddda3e32fd8a0e75dc39d8a4191bb742157fb"
url: "https://api.replicate.com/v1/predictions" url: "https://api.replicate.com/v1/predictions"
stream: false stream: false
chat-tts:
version: "fdb4f547d19c9591d7e0223c88b14886c110129c0e206ddbb97fe7a344162868"
url: "https://api.replicate.com/v1/predictions"
stream: false
whisper:
version: "be69de6b9dc57b3361dff4122ef4d6876ad4234bf5c879287b48d35c20ce3e83"
url: "https://api.replicate.com/v1/predictions"
stream: false
controlnet:
version: "795433b19458d0f4fa172a7ccf93178d2adb1cb8ab2ad6c8fdc33fdbcd49f477"
url: "https://api.replicate.com/v1/predictions"
stream: false
blip:
version: "2e1dddc8621f72155f24cf2e0adbde548458d3cab9f00c0139eea840d0ac4746"
url: "https://api.replicate.com/v1/predictions"
stream: false
gfpgan:
version: "66a607f2c8ee93966fb2759b0bb93f48a707f46d2f75df5d66db73d3b5d8337d"
url: "https://api.replicate.com/v1/predictions"
stream: false
sdxl:
version: "7762fd07cf82c948538e41f63f77d685e02b063e37e496e96eefd46c929f9bdc"
url: "https://api.replicate.com/v1/predictions"
stream: false
minigpt-4:
version: "e447a8583cffd86ce3b93f9c2cd24f2eae603d99ace6afa94b33a08e94a3cd06"
url: "https://api.replicate.com/v1/predictions"
stream: false
codeformer:
version: "78f2bab438ab0ffc85a68cdfd316a2ecd3994b5dd26aa6b3d203357b45e5eb1b"
url: "https://api.replicate.com/v1/predictions"
stream: false
real-esrgan:
version: "f121d640bd286e1fdc67f9799164c1d5be36ff74576ee11c803ae5b665dd46aa"
url: "https://api.replicate.com/v1/predictions"
stream: false
blip-2:
version: "f677695e5e89f8b236e52ecd1d3f01beb44c34606419bcc19345e046d8f786f9"
url: "https://api.replicate.com/v1/predictions"
stream: false
bark:
version: "b76242b40d67c76ab6742e987628a2a9ac019e11d56ab96c4e91ce03b79b2787"
url: "https://api.replicate.com/v1/predictions"
stream: false
dreambooth-batch:
version: "0de6c0b01bd739f96052a4564ca1c8a53ed5246de86c0ef86ca8abe28f9aacad"
url: "https://api.replicate.com/v1/predictions"
stream: false
dreambooth:
version: "a8ba568da0313951a6b311b43b1ea3bf9f2ef7b9fd97ed94cebd7ffd2da66654"
url: "https://api.replicate.com/v1/predictions"
stream: false
\ No newline at end of file
...@@ -81,6 +81,19 @@ func (server *TaskController) Prediction() { ...@@ -81,6 +81,19 @@ func (server *TaskController) Prediction() {
server.respond(http.StatusOK, err.Error()) server.respond(http.StatusOK, err.Error())
return return
} }
if async {
response := struct {
Task *models.TaskReturn `json:"task"`
ExcuteId string `json:"excute_id"`
}{
Task: &models.TaskReturn{
Async: async,
},
ExcuteId: task.ExcuteId,
}
server.respond(http.StatusOK, "", response)
return
}
server.respond(http.StatusOK, "", result) server.respond(http.StatusOK, "", result)
} }
...@@ -301,7 +314,9 @@ func uploadToS3(bucket, key string, img image.Image, format string) (string, err ...@@ -301,7 +314,9 @@ func uploadToS3(bucket, key string, img image.Image, format string) (string, err
timestamp := time.Now().Unix() timestamp := time.Now().Unix()
timestampStr := strconv.FormatInt(timestamp, 10) timestampStr := strconv.FormatInt(timestamp, 10)
key = filePath + "/" + timestampStr + "_" + key width := img.Bounds().Dx()
height := img.Bounds().Dy()
key = filePath + "/" + timestampStr + "_" + "width=" + strconv.Itoa(width) + "&height=" + strconv.Itoa(height) + "_" + key
_, err = client.PutObject(context.TODO(), &s3.PutObjectInput{ _, err = client.PutObject(context.TODO(), &s3.PutObjectInput{
Bucket: aws.String(bucket), Bucket: aws.String(bucket),
...@@ -729,6 +744,18 @@ func doGetReplicate(url string, task *models.Task, taskResponse *models.TaskResp ...@@ -729,6 +744,18 @@ func doGetReplicate(url string, task *models.Task, taskResponse *models.TaskResp
output = append(output, value) output = append(output, value)
} }
}
if slice, ok := temp.Output.(map[string]interface{}); ok {
fmt.Println("i 是map类型,值为:", slice)
for _, value := range slice {
logs.Info("getReplicate value:", value)
if str, ok1 := value.(string); ok1 {
fmt.Println("i 是字符串类型,值为:", str)
output = append(output, str)
}
//output = append(output, value)
}
} }
task.Status = 2 task.Status = 2
isImage := checkFileIsImage(output) isImage := checkFileIsImage(output)
......
{"/Users/brent/Documents/wubanWork/aon_app_server/controllers":1722309597368049052} {"/Users/brent/Documents/wubanWork/aon_app_server/controllers":1723107582385421558}
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment