-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
42 lines (40 loc) · 1.3 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"context"
"fmt"
"github.com/omniinfer/golang-sdk/request"
"github.com/omniinfer/golang-sdk/types"
"time"
)
func main() {
// get your api key refer to https://docs.omniinfer.io/get-started/
const apiKey = "your-key"
client, err := request.NewOmniClient(apiKey)
if err != nil {
fmt.Printf("new omniclient failed, %v\n", err)
return
}
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*3)
defer cancel()
modelList, err := client.Models(ctx)
if err != nil {
fmt.Printf("get models list failed, %v\n", err)
return
}
// Anything V5/Ink, https://civitai.com/models/9409/or-anything-v5ink
modelName := modelList.FilterCivitaiVersionId(90854).SdName
// Detail Tweaker LoRA, https://civitai.com/models/58390/detail-tweaker-lora-lora
loraName := modelList.FilterCivitaiVersionId(62833).SdName
txt2ImgReq := types.NewTxt2ImgRequest(fmt.Sprintf("a dog flying in the sky, <lora:%s:%d>", loraName, 1), "", modelName)
res, err := client.SyncTxt2img(ctx, txt2ImgReq,
request.WithSaveImage("out", 0777, func(taskId string, fileIndex int, fileName string) string {
return "test_txt2img_sync.png"
}))
if err != nil {
fmt.Printf("generate image failed, %v\n", err)
return
}
for _, s3Url := range res.Data.Imgs {
fmt.Printf("generate image url: %v\n", s3Url)
}
}