sun-pc-linux 1 주 전
부모
커밋
991830789c
8개의 변경된 파일573개의 추가작업 그리고 539개의 파일을 삭제
  1. 175 175
      gen/http.go
  2. 183 183
      main.go
  3. 36 36
      model/result.go
  4. 66 66
      oss/aliyun.go
  5. 34 0
      qutter.ps1
  6. 45 45
      readme.md
  7. 4 4
      tryonpy/try.bat
  8. 30 30
      tryonpy/tryOn.py

+ 175 - 175
gen/http.go

@@ -1,175 +1,175 @@
-package gen
-
-import (
-	"bytes"
-	"encoding/json"
-	"errors"
-	"fmt"
-	"io"
-	"net/http"
-	"os"
-	"time"
-	"tryon/model"
-)
-
-const (
-	API_URL           = "https://dashscope.aliyuncs.com/api/v1/services/aigc/virtualmodel/generation/"
-	DASHSCOPE_API_KEY = "sk-36a7725c51be4ffe8d3374ea534014b6"
-)
-
-type OutPutRes struct {
-	OutPut    OutPut `json:"output"`
-	RequestId string `json:"request_id"`
-}
-type OutPut struct {
-	TaskStatus string `json:"task_status"`
-	TaskId     string `json:"task_id"`
-}
-
-func Generate(model string, shoes []string, scale float64) (string, error) {
-	fmt.Println(scale)
-	// 设置请求体
-	data := map[string]interface{}{
-		"model": "shoemodel-v1",
-		"input": map[string]interface{}{
-			"template_image_url": model,
-			"shoe_image_url":     shoes,
-			"scale":              scale,
-		},
-		"parameters": map[string]interface{}{
-			"n": 1,
-		},
-	}
-	// 将请求体编码为 JSON
-	jsonData, err := json.Marshal(data)
-	if err != nil {
-		return "", nil
-	}
-
-	req, err := http.NewRequest("POST", API_URL, bytes.NewBuffer(jsonData))
-	if err != nil {
-		return "", nil
-	}
-
-	// 设置请求头
-	req.Header.Set("X-DashScope-Async", "enable")
-	req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", DASHSCOPE_API_KEY))
-	req.Header.Set("Content-Type", "application/json")
-
-	// 发起 POST 请求
-	client := &http.Client{}
-	resp, err := client.Do(req)
-	if err != nil {
-		return "", err
-	}
-	defer resp.Body.Close()
-
-	// 读取响应
-	body, err := io.ReadAll(resp.Body)
-	if err != nil {
-		return "", err
-	}
-
-	bodyObj := OutPutRes{}
-	err = json.Unmarshal(body, &bodyObj)
-	if err != nil {
-		return "", err
-	}
-	fmt.Println(bodyObj)
-	return bodyObj.OutPut.TaskId, nil
-
-}
-
-func GetReslut(taskId string, outPut string) (string, error) {
-	if len(taskId) == 0 {
-		return "", errors.New("taskId is empty")
-	}
-
-	// 获取任务 ID
-	// taskID := "6488c66d-2a0c-4134-90bb-39ab957d6cdf"
-	returl := fmt.Sprintf("https://dashscope.aliyuncs.com/api/v1/tasks/%s", taskId)
-
-	// 创建 GET 请求
-	getReq, err := http.NewRequest("GET", returl, nil)
-	if err != nil {
-		return "", err
-	}
-
-	// 设置 GET 请求头
-	getReq.Header.Set("Authorization", fmt.Sprintf("Bearer %s", DASHSCOPE_API_KEY))
-
-	// 发起 GET 请求
-	client := &http.Client{}
-	getResp, err := client.Do(getReq)
-	if err != nil {
-		return "", err
-	}
-	defer getResp.Body.Close()
-
-	// 读取响应
-	getBody, err := io.ReadAll(getResp.Body)
-	if err != nil {
-		return "", err
-	}
-	bodyObj := model.Response{}
-	err = json.Unmarshal(getBody, &bodyObj)
-	if err != nil {
-		return "", err
-	}
-	fmt.Printf("%#v\n", bodyObj)
-	if bodyObj.Output.TaskStatus == "SUCCEEDED" {
-		// 下载到本地
-		return bodyObj.Output.Results[0].URL, nil
-	}
-	return bodyObj.Output.TaskStatus, errors.New("后台处理中。。。")
-
-	// {
-	//     "request_id": "a052b714-29d5-92c0-b981-43dc027523db",
-	//     "output": {
-	//         "task_id": "5f6316e3-ef6c-4143-abb5-81ffefdbfcd0",
-	//         "task_status": "SUCCEEDED",
-	//         "submit_time": "2024-11-04 16:27:38.824",
-	//         "scheduled_time": "2024-11-04 16:27:38.852",
-	//         "end_time": "2024-11-04 16:27:54.092",
-	//         "results": [
-	//             {
-	//                 "url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/7d/08/20241104/18d9de26/2024-11-04/42b28ff3-8e67-44fa-805e-72cab9e204fc-1/res_img.png?Expires=1730795274&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=KlU2NsBfFKDcl9NwklzH1i2X8bk%3D"
-	//             }
-	//         ],
-	//         "task_metrics": {
-	//             "TOTAL": 1,
-	//             "SUCCEEDED": 1,
-	//             "FAILED": 0
-	//         }
-	//     },
-	//     "usage": {
-	//         "image_count": 1
-	//     }
-	// }
-}
-
-func Download(url string, outPut string) (string, error) {
-	// 创建 GET 请求
-	resp, err := http.Get(url)
-	if err != nil {
-		return "", err
-	}
-	defer resp.Body.Close() // 确保在函数返回时关闭响应体
-
-	key := time.Now().Format("20060102_150405")
-	outPutFile := fmt.Sprintf("%s/%s.png", outPut, key)
-
-	out, err := os.Create(outPutFile)
-	if err != nil {
-		return "", err
-	}
-	defer out.Close()
-
-	_, err = io.Copy(out, resp.Body)
-	if err != nil {
-		return "", err
-	}
-
-	return outPutFile, nil
-
-}
+package gen
+
+import (
+	"bytes"
+	"encoding/json"
+	"errors"
+	"fmt"
+	"io"
+	"net/http"
+	"os"
+	"time"
+	"tryon/model"
+)
+
+const (
+	API_URL           = "https://dashscope.aliyuncs.com/api/v1/services/aigc/virtualmodel/generation/"
+	DASHSCOPE_API_KEY = "sk-36a7725c51be4ffe8d3374ea534014b6"
+)
+
+type OutPutRes struct {
+	OutPut    OutPut `json:"output"`
+	RequestId string `json:"request_id"`
+}
+type OutPut struct {
+	TaskStatus string `json:"task_status"`
+	TaskId     string `json:"task_id"`
+}
+
+func Generate(model string, shoes []string, scale float64) (string, error) {
+	fmt.Println(scale)
+	// 设置请求体
+	data := map[string]interface{}{
+		"model": "shoemodel-v1",
+		"input": map[string]interface{}{
+			"template_image_url": model,
+			"shoe_image_url":     shoes,
+			"scale":              scale,
+		},
+		"parameters": map[string]interface{}{
+			"n": 1,
+		},
+	}
+	// 将请求体编码为 JSON
+	jsonData, err := json.Marshal(data)
+	if err != nil {
+		return "", nil
+	}
+
+	req, err := http.NewRequest("POST", API_URL, bytes.NewBuffer(jsonData))
+	if err != nil {
+		return "", nil
+	}
+
+	// 设置请求头
+	req.Header.Set("X-DashScope-Async", "enable")
+	req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", DASHSCOPE_API_KEY))
+	req.Header.Set("Content-Type", "application/json")
+
+	// 发起 POST 请求
+	client := &http.Client{}
+	resp, err := client.Do(req)
+	if err != nil {
+		return "", err
+	}
+	defer resp.Body.Close()
+
+	// 读取响应
+	body, err := io.ReadAll(resp.Body)
+	if err != nil {
+		return "", err
+	}
+
+	bodyObj := OutPutRes{}
+	err = json.Unmarshal(body, &bodyObj)
+	if err != nil {
+		return "", err
+	}
+	fmt.Println(bodyObj)
+	return bodyObj.OutPut.TaskId, nil
+
+}
+
+func GetReslut(taskId string, outPut string) (string, error) {
+	if len(taskId) == 0 {
+		return "", errors.New("taskId is empty")
+	}
+
+	// 获取任务 ID
+	// taskID := "6488c66d-2a0c-4134-90bb-39ab957d6cdf"
+	returl := fmt.Sprintf("https://dashscope.aliyuncs.com/api/v1/tasks/%s", taskId)
+
+	// 创建 GET 请求
+	getReq, err := http.NewRequest("GET", returl, nil)
+	if err != nil {
+		return "", err
+	}
+
+	// 设置 GET 请求头
+	getReq.Header.Set("Authorization", fmt.Sprintf("Bearer %s", DASHSCOPE_API_KEY))
+
+	// 发起 GET 请求
+	client := &http.Client{}
+	getResp, err := client.Do(getReq)
+	if err != nil {
+		return "", err
+	}
+	defer getResp.Body.Close()
+
+	// 读取响应
+	getBody, err := io.ReadAll(getResp.Body)
+	if err != nil {
+		return "", err
+	}
+	bodyObj := model.Response{}
+	err = json.Unmarshal(getBody, &bodyObj)
+	if err != nil {
+		return "", err
+	}
+	fmt.Printf("%#v\n", bodyObj)
+	if bodyObj.Output.TaskStatus == "SUCCEEDED" {
+		// 下载到本地
+		return bodyObj.Output.Results[0].URL, nil
+	}
+	return bodyObj.Output.TaskStatus, errors.New("后台处理中。。。")
+
+	// {
+	//     "request_id": "a052b714-29d5-92c0-b981-43dc027523db",
+	//     "output": {
+	//         "task_id": "5f6316e3-ef6c-4143-abb5-81ffefdbfcd0",
+	//         "task_status": "SUCCEEDED",
+	//         "submit_time": "2024-11-04 16:27:38.824",
+	//         "scheduled_time": "2024-11-04 16:27:38.852",
+	//         "end_time": "2024-11-04 16:27:54.092",
+	//         "results": [
+	//             {
+	//                 "url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/7d/08/20241104/18d9de26/2024-11-04/42b28ff3-8e67-44fa-805e-72cab9e204fc-1/res_img.png?Expires=1730795274&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=KlU2NsBfFKDcl9NwklzH1i2X8bk%3D"
+	//             }
+	//         ],
+	//         "task_metrics": {
+	//             "TOTAL": 1,
+	//             "SUCCEEDED": 1,
+	//             "FAILED": 0
+	//         }
+	//     },
+	//     "usage": {
+	//         "image_count": 1
+	//     }
+	// }
+}
+
+func Download(url string, outPut string) (string, error) {
+	// 创建 GET 请求
+	resp, err := http.Get(url)
+	if err != nil {
+		return "", err
+	}
+	defer resp.Body.Close() // 确保在函数返回时关闭响应体
+
+	key := time.Now().Format("20060102_150405")
+	outPutFile := fmt.Sprintf("%s/%s.png", outPut, key)
+
+	out, err := os.Create(outPutFile)
+	if err != nil {
+		return "", err
+	}
+	defer out.Close()
+
+	_, err = io.Copy(out, resp.Body)
+	if err != nil {
+		return "", err
+	}
+
+	return outPutFile, nil
+
+}

+ 183 - 183
main.go

@@ -1,183 +1,183 @@
-package main
-
-import (
-	"fmt"
-	"os"
-	"path/filepath"
-	"strings"
-	"time"
-	"tryon/gen"
-	"tryon/oss"
-
-	"github.com/jessevdk/go-flags"
-)
-
-var GAppOption = &AppOption{}
-
-// short只能是一个字符
-type AppOption struct {
-	Model string   `short:"m" long:"model" description:"model image"`
-	Scale float64  `short:"c" long:"scale" description:"scale [2.0-8.0] default 5.0"`
-	Shoes []string `short:"s" long:"shoes" description:"shoes images"`
-}
-
-func (o *AppOption) Parse() error {
-	_, err := flags.NewParser(o, flags.Default|flags.IgnoreUnknown).Parse()
-	return err
-
-}
-
-const (
-	LOCAL_MODEL_DIR = "models"
-	LOCAL_SHOES_DIR = "shoes"
-	OUTPUT_DIR      = "output"
-)
-
-func main() {
-	os.Mkdir(OUTPUT_DIR, os.ModePerm)
-	// 读取命令行参数 获取图片
-	// go run . -m xxx.png -s xx.png -s xx.png
-	err := GAppOption.Parse()
-	if err != nil {
-		fmt.Println(err)
-		return
-	}
-
-	// 适配/设置默认scale
-	if GAppOption.Scale == 0 {
-		GAppOption.Scale = 5.01
-	}
-	if GAppOption.Scale < 2 {
-		GAppOption.Scale = 2.01
-	}
-	if GAppOption.Scale > 8 {
-		GAppOption.Scale = 7.99
-	}
-
-	// 获取shoes目录中图片
-	if len(GAppOption.Shoes) == 0 {
-		files, err := getAllFilesInDir(LOCAL_SHOES_DIR)
-		if err != nil {
-			fmt.Println("获取shoes文件失败: ", err)
-			return
-		}
-		GAppOption.Shoes = append(GAppOption.Shoes, files...)
-	}
-
-	if len(GAppOption.Model) == 0 || len(GAppOption.Shoes) == 0 {
-		fmt.Println("缺失图片参数!")
-		return
-	}
-	// 根据参数拼接图片所在当前完整路径
-	modelLocalImage := fmt.Sprintf("%s/%s", LOCAL_MODEL_DIR, GAppOption.Model)
-	shoesLocalImages := []string{}
-	fmt.Println(len(shoesLocalImages))
-	for _, shoe := range GAppOption.Shoes {
-		shoesLocalImages = append(shoesLocalImages, fmt.Sprintf("%s/%s", LOCAL_SHOES_DIR, shoe))
-	}
-	ossReslut, err := oss.UpladImages(modelLocalImage, shoesLocalImages)
-	if err != nil {
-		fmt.Println(err)
-		return
-	}
-	fmt.Println("上传结果: ", ossReslut)
-	if len(ossReslut.Model) == 0 || len(ossReslut.Shoes) == 0 {
-		fmt.Println("上传图片出错")
-		return
-	}
-	taskId, err := gen.Generate(ossReslut.Model, ossReslut.Shoes, GAppOption.Scale)
-	fmt.Println("taskId: ", taskId)
-	if err != nil {
-		fmt.Println(err)
-		return
-	}
-
-	// 延迟
-	fmt.Println("等待处理。。。")
-	time.Sleep(3 * time.Second)
-
-	// 这里成功返回url,失败返回""/status
-	url, err := gen.GetReslut(taskId, OUTPUT_DIR)
-	fmt.Println("url: ", url)
-	if err != nil {
-		fmt.Println(err)
-		if len(url) == 0 {
-			return
-		}
-		if url == "FAILED" {
-			fmt.Println("后台处理失败status[FAILED]")
-			return
-
-		}
-		// 重新查询
-		replay := 10
-		for {
-			if replay == 0 {
-				fmt.Printf("status: %s,任务处理中,请多等待...", url)
-				return
-			}
-			time.Sleep(5 * time.Second)
-			url, err = gen.GetReslut(taskId, OUTPUT_DIR)
-			if err != nil {
-				// 重试逻辑
-				if len(url) > 0 {
-					if url == "FAILED" {
-						fmt.Println("后台处理失败status[FAILED]")
-						return
-					}
-					replay--
-				} else {
-					// 异常逻辑
-					fmt.Println(err)
-					return
-				}
-			} else {
-				// 成功跳出
-				break
-			}
-
-		}
-	}
-	fmt.Println("url---> : ", url)
-
-	dist, err := gen.Download(url, OUTPUT_DIR)
-	if err != nil {
-		fmt.Println(err)
-		return
-	}
-	fmt.Println("获取结果: ", dist)
-
-}
-
-// 获取某个目录下的所有文件路径,递归遍历,并生成相对路径
-func getAllFilesInDir(baseDir string) ([]string, error) {
-	var files []string
-
-	// filepath.Walk 会递归遍历目录及子目录
-	err := filepath.Walk(baseDir, func(path string, info os.FileInfo, err error) error {
-		// 遇到错误直接返回
-		if err != nil {
-			return err
-		}
-
-		// 跳过目录,只处理文件
-		if !info.IsDir() {
-			// 计算相对路径
-			relPath, err := filepath.Rel(baseDir, path)
-			if err != nil {
-				return err
-			}
-
-			// 将路径中的反斜杠替换为正斜杠
-			relPath = strings.ReplaceAll(relPath, "\\", "/")
-
-			// 将相对路径加入文件列表
-			files = append(files, relPath)
-		}
-		return nil
-	})
-	if err != nil {
-		return nil, err
-	}
-	return files, nil
-}
+package main
+
+import (
+	"fmt"
+	"os"
+	"path/filepath"
+	"strings"
+	"time"
+	"tryon/gen"
+	"tryon/oss"
+
+	"github.com/jessevdk/go-flags"
+)
+
+var GAppOption = &AppOption{}
+
+// short只能是一个字符
+type AppOption struct {
+	Model string   `short:"m" long:"model" description:"model image"`
+	Scale float64  `short:"c" long:"scale" description:"scale [2.0-8.0] default 5.0"`
+	Shoes []string `short:"s" long:"shoes" description:"shoes images"`
+}
+
+func (o *AppOption) Parse() error {
+	_, err := flags.NewParser(o, flags.Default|flags.IgnoreUnknown).Parse()
+	return err
+
+}
+
+const (
+	LOCAL_MODEL_DIR = "models"
+	LOCAL_SHOES_DIR = "shoes"
+	OUTPUT_DIR      = "output"
+)
+
+func main() {
+	os.Mkdir(OUTPUT_DIR, os.ModePerm)
+	// 读取命令行参数 获取图片
+	// go run . -m xxx.png -s xx.png -s xx.png
+	err := GAppOption.Parse()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	// 适配/设置默认scale
+	if GAppOption.Scale == 0 {
+		GAppOption.Scale = 5.01
+	}
+	if GAppOption.Scale < 2 {
+		GAppOption.Scale = 2.01
+	}
+	if GAppOption.Scale > 8 {
+		GAppOption.Scale = 7.99
+	}
+
+	// 获取shoes目录中图片
+	if len(GAppOption.Shoes) == 0 {
+		files, err := getAllFilesInDir(LOCAL_SHOES_DIR)
+		if err != nil {
+			fmt.Println("获取shoes文件失败: ", err)
+			return
+		}
+		GAppOption.Shoes = append(GAppOption.Shoes, files...)
+	}
+
+	if len(GAppOption.Model) == 0 || len(GAppOption.Shoes) == 0 {
+		fmt.Println("缺失图片参数!")
+		return
+	}
+	// 根据参数拼接图片所在当前完整路径
+	modelLocalImage := fmt.Sprintf("%s/%s", LOCAL_MODEL_DIR, GAppOption.Model)
+	shoesLocalImages := []string{}
+	fmt.Println(len(shoesLocalImages))
+	for _, shoe := range GAppOption.Shoes {
+		shoesLocalImages = append(shoesLocalImages, fmt.Sprintf("%s/%s", LOCAL_SHOES_DIR, shoe))
+	}
+	ossReslut, err := oss.UpladImages(modelLocalImage, shoesLocalImages)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("上传结果: ", ossReslut)
+	if len(ossReslut.Model) == 0 || len(ossReslut.Shoes) == 0 {
+		fmt.Println("上传图片出错")
+		return
+	}
+	taskId, err := gen.Generate(ossReslut.Model, ossReslut.Shoes, GAppOption.Scale)
+	fmt.Println("taskId: ", taskId)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	// 延迟
+	fmt.Println("等待处理。。。")
+	time.Sleep(3 * time.Second)
+
+	// 这里成功返回url,失败返回""/status
+	url, err := gen.GetReslut(taskId, OUTPUT_DIR)
+	fmt.Println("url: ", url)
+	if err != nil {
+		fmt.Println(err)
+		if len(url) == 0 {
+			return
+		}
+		if url == "FAILED" {
+			fmt.Println("后台处理失败status[FAILED]")
+			return
+
+		}
+		// 重新查询
+		replay := 10
+		for {
+			if replay == 0 {
+				fmt.Printf("status: %s,任务处理中,请多等待...", url)
+				return
+			}
+			time.Sleep(5 * time.Second)
+			url, err = gen.GetReslut(taskId, OUTPUT_DIR)
+			if err != nil {
+				// 重试逻辑
+				if len(url) > 0 {
+					if url == "FAILED" {
+						fmt.Println("后台处理失败status[FAILED]")
+						return
+					}
+					replay--
+				} else {
+					// 异常逻辑
+					fmt.Println(err)
+					return
+				}
+			} else {
+				// 成功跳出
+				break
+			}
+
+		}
+	}
+	fmt.Println("url---> : ", url)
+
+	dist, err := gen.Download(url, OUTPUT_DIR)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	fmt.Println("获取结果: ", dist)
+
+}
+
+// 获取某个目录下的所有文件路径,递归遍历,并生成相对路径
+func getAllFilesInDir(baseDir string) ([]string, error) {
+	var files []string
+
+	// filepath.Walk 会递归遍历目录及子目录
+	err := filepath.Walk(baseDir, func(path string, info os.FileInfo, err error) error {
+		// 遇到错误直接返回
+		if err != nil {
+			return err
+		}
+
+		// 跳过目录,只处理文件
+		if !info.IsDir() {
+			// 计算相对路径
+			relPath, err := filepath.Rel(baseDir, path)
+			if err != nil {
+				return err
+			}
+
+			// 将路径中的反斜杠替换为正斜杠
+			relPath = strings.ReplaceAll(relPath, "\\", "/")
+
+			// 将相对路径加入文件列表
+			files = append(files, relPath)
+		}
+		return nil
+	})
+	if err != nil {
+		return nil, err
+	}
+	return files, nil
+}

+ 36 - 36
model/result.go

@@ -1,36 +1,36 @@
-package model
-
-// Response 结构体对应整个JSON响应
-type Response struct {
-	RequestID string `json:"request_id"`
-	Output    Output `json:"output"`
-	Usage     Usage  `json:"usage"`
-}
-
-// Output 结构体对应输出部分的JSON数据
-type Output struct {
-	TaskID     string `json:"task_id"`
-	TaskStatus string `json:"task_status"`
-	// SubmitTime    time.Time   `json:"submit_time"`
-	// ScheduledTime time.Time   `json:"scheduled_time"`
-	// EndTime       time.Time   `json:"end_time"`
-	Results     []Result    `json:"results"`
-	TaskMetrics TaskMetrics `json:"task_metrics"`
-}
-
-// Result 结构体对应结果数组中的每个元素
-type Result struct {
-	URL string `json:"url"`
-}
-
-// TaskMetrics 结构体对应任务指标部分的JSON数据
-type TaskMetrics struct {
-	TOTAL     int `json:"TOTAL"`
-	SUCCEEDED int `json:"SUCCEEDED"`
-	FAILED    int `json:"FAILED"`
-}
-
-// Usage 结构体对应使用情况部分的JSON数据
-type Usage struct {
-	ImageCount int `json:"image_count"`
-}
+package model
+
+// Response 结构体对应整个JSON响应
+type Response struct {
+	RequestID string `json:"request_id"`
+	Output    Output `json:"output"`
+	Usage     Usage  `json:"usage"`
+}
+
+// Output 结构体对应输出部分的JSON数据
+type Output struct {
+	TaskID     string `json:"task_id"`
+	TaskStatus string `json:"task_status"`
+	// SubmitTime    time.Time   `json:"submit_time"`
+	// ScheduledTime time.Time   `json:"scheduled_time"`
+	// EndTime       time.Time   `json:"end_time"`
+	Results     []Result    `json:"results"`
+	TaskMetrics TaskMetrics `json:"task_metrics"`
+}
+
+// Result 结构体对应结果数组中的每个元素
+type Result struct {
+	URL string `json:"url"`
+}
+
+// TaskMetrics 结构体对应任务指标部分的JSON数据
+type TaskMetrics struct {
+	TOTAL     int `json:"TOTAL"`
+	SUCCEEDED int `json:"SUCCEEDED"`
+	FAILED    int `json:"FAILED"`
+}
+
+// Usage 结构体对应使用情况部分的JSON数据
+type Usage struct {
+	ImageCount int `json:"image_count"`
+}

+ 66 - 66
oss/aliyun.go

@@ -1,66 +1,66 @@
-package oss
-
-import (
-	"fmt"
-	"log"
-
-	"github.com/aliyun/aliyun-oss-go-sdk/oss"
-)
-
-const (
-	ENDPOINT      = "oss-cn-beijing.aliyuncs.com"
-	ACCESS_KEY    = "LTAI5tBUvFtfWU4H3AikcmwF"
-	ACCESS_SECRET = "W7Yceh0A0RODc6bELpcML1xHZOQ32q"
-	BUCKET        = "infish-oss"
-)
-
-func CreateClient() {
-	_, err := oss.New(ENDPOINT, ACCESS_KEY, ACCESS_SECRET)
-	if err != nil {
-		panic(err)
-	}
-
-	return
-
-}
-
-type UpladImagesRes struct {
-	Model string
-	Shoes []string
-}
-
-func UpladImages(model string, shoes []string) (UpladImagesRes, error) {
-
-	cli, err := oss.New(ENDPOINT, ACCESS_KEY, ACCESS_SECRET)
-	if err != nil {
-		log.Fatalf("Error: %v", err)
-		return UpladImagesRes{}, err
-	}
-
-	// 获取存储空间
-	bucket, err := cli.Bucket(BUCKET)
-	if err != nil {
-		return UpladImagesRes{}, err
-	}
-	res := UpladImagesRes{}
-	localFileName := model
-	objectName := fmt.Sprintf("tryon/%s", model)
-	err = bucket.PutObjectFromFile(objectName, localFileName)
-	if err != nil {
-		return UpladImagesRes{}, err
-	}
-	res.Model = fmt.Sprintf("https://infish-oss.oss-cn-beijing.aliyuncs.com/%s", objectName)
-
-	for _, shoe := range shoes {
-		localFileName = shoe
-		objectName = fmt.Sprintf("tryon/%s", shoe)
-		err = bucket.PutObjectFromFile(objectName, localFileName)
-		if err != nil {
-			fmt.Println(err)
-			continue
-		}
-		res.Shoes = append(res.Shoes, fmt.Sprintf("https://infish-oss.oss-cn-beijing.aliyuncs.com/%s", objectName))
-	}
-
-	return res, nil
-}
+package oss
+
+import (
+	"fmt"
+	"log"
+
+	"github.com/aliyun/aliyun-oss-go-sdk/oss"
+)
+
+const (
+	ENDPOINT      = "oss-cn-beijing.aliyuncs.com"
+	ACCESS_KEY    = "LTAI5tBUvFtfWU4H3AikcmwF"
+	ACCESS_SECRET = "W7Yceh0A0RODc6bELpcML1xHZOQ32q"
+	BUCKET        = "infish-oss"
+)
+
+func CreateClient() {
+	_, err := oss.New(ENDPOINT, ACCESS_KEY, ACCESS_SECRET)
+	if err != nil {
+		panic(err)
+	}
+
+	return
+
+}
+
+type UpladImagesRes struct {
+	Model string
+	Shoes []string
+}
+
+func UpladImages(model string, shoes []string) (UpladImagesRes, error) {
+
+	cli, err := oss.New(ENDPOINT, ACCESS_KEY, ACCESS_SECRET)
+	if err != nil {
+		log.Fatalf("Error: %v", err)
+		return UpladImagesRes{}, err
+	}
+
+	// 获取存储空间
+	bucket, err := cli.Bucket(BUCKET)
+	if err != nil {
+		return UpladImagesRes{}, err
+	}
+	res := UpladImagesRes{}
+	localFileName := model
+	objectName := fmt.Sprintf("tryon/%s", model)
+	err = bucket.PutObjectFromFile(objectName, localFileName)
+	if err != nil {
+		return UpladImagesRes{}, err
+	}
+	res.Model = fmt.Sprintf("https://infish-oss.oss-cn-beijing.aliyuncs.com/%s", objectName)
+
+	for _, shoe := range shoes {
+		localFileName = shoe
+		objectName = fmt.Sprintf("tryon/%s", shoe)
+		err = bucket.PutObjectFromFile(objectName, localFileName)
+		if err != nil {
+			fmt.Println(err)
+			continue
+		}
+		res.Shoes = append(res.Shoes, fmt.Sprintf("https://infish-oss.oss-cn-beijing.aliyuncs.com/%s", objectName))
+	}
+
+	return res, nil
+}

+ 34 - 0
qutter.ps1

@@ -0,0 +1,34 @@
+#Requires -version 3
+Param(
+    [string]$Password = $null
+)
+
+# When testing or debugging your script, you can quickly display a message box
+[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
+
+
+# Function to check password complexity
+Function Check-PasswordComplexity {
+    param (
+        [string]$Password
+    )
+    $BuiltInPassword = "123456!"
+		AI_SetMsiProperty PASS_STRONG ""
+
+    # Check if all requirements are met
+    if ($Password -eq $BuiltInPassword) {
+        $A = 1
+				Write-Host "Password meets the security standards."
+				AI_SetMsiProperty PASS_STRONG "true"
+
+    } else {
+        Write-Host "Password does not meet the security standards. Make sure your password is:"
+
+
+				AI_SetMsiProperty PASS_STRONG "false"
+				[System.Windows.Forms.MessageBox]::Show("密码错误!")
+    }
+}
+
+$Password = AI_GetMsiProperty USER_PASSWORD
+Check-PasswordComplexity -Password $Password

+ 45 - 45
readme.md

@@ -1,45 +1,45 @@
-# 功能描述
-
-> 根据模型和多张鞋子图片合成图片
-
-1. 读取命令行参数 获取图片
-2. 上传图片到oss
-3. 生成结果图片下载到本地目录
-
-## 命令说明
-
-```sh
-# 默认目录 -m ./models -s ./shoes
-# 默认 scale 5.0 [2.0-8.0] 数字越大越鲜亮
-# 完整参数示例
-/tryon.exe -m model2.jpg -c 5.6 -s shoe2.png -s shoe3.png
-
-# 简化参数示例
-/tryon.exe -m model2.jpg
-```sh
-
-```md
-输入限制
-
-模特模板图:
-
-图片分辨率:长宽比小于3:2,推荐为4:3。
-
-图片格式:JPEG,PNG,JPG,BMP,WEB,AVIF。
-
-图片大小:建议不超过5M。
-
-鞋靴多视角图:
-
-图片分辨率:长宽比小于3:2,推荐与模特模板图一样,尽量为4:3。
-
-图片格式:JPEG,PNG,JPG,BMP,WEB,AVIF。
-
-图片大小:建议不超过5M。
-
-图片个数:多视角图片个数小于3。
-
-URL地址:
-
-不能包含中文字符。
-```md
+# 功能描述
+
+> 根据模型和多张鞋子图片合成图片
+
+1. 读取命令行参数 获取图片
+2. 上传图片到oss
+3. 生成结果图片下载到本地目录
+
+## 命令说明
+
+```sh
+# 默认目录 -m ./models -s ./shoes
+# 默认 scale 5.0 [2.0-8.0] 数字越大越鲜亮
+# 完整参数示例
+/tryon.exe -m model2.jpg -c 5.6 -s shoe2.png -s shoe3.png
+
+# 简化参数示例
+/tryon.exe -m model2.jpg
+```sh
+
+```md
+输入限制
+
+模特模板图:
+
+图片分辨率:长宽比小于3:2,推荐为4:3。
+
+图片格式:JPEG,PNG,JPG,BMP,WEB,AVIF。
+
+图片大小:建议不超过5M。
+
+鞋靴多视角图:
+
+图片分辨率:长宽比小于3:2,推荐与模特模板图一样,尽量为4:3。
+
+图片格式:JPEG,PNG,JPG,BMP,WEB,AVIF。
+
+图片大小:建议不超过5M。
+
+图片个数:多视角图片个数小于3。
+
+URL地址:
+
+不能包含中文字符。
+```md

+ 4 - 4
tryonpy/try.bat

@@ -1,5 +1,5 @@
-
-@REM /tryon.exe -m model2.jpg -c 5.6 -s shoe2.png -s shoe3.png
-@REM 默认 scale 5.0 [2.0-8.0] 数字越大越鲜亮
-
+
+@REM /tryon.exe -m model2.jpg -c 5.6 -s shoe2.png -s shoe3.png
+@REM 默认 scale 5.0 [2.0-8.0] 数字越大越鲜亮
+
 /tryon.exe -m model2.jpg

+ 30 - 30
tryonpy/tryOn.py

@@ -1,31 +1,31 @@
-import requests
-
-url = 'https://dashscope.aliyuncs.com/api/v1/services/aigc/virtualmodel/generation/'
-DASHSCOPE_API_KEY = "sk-36a7725c51be4ffe8d3374ea534014b6"
-headers = {
-    'X-DashScope-Async': 'enable',
-    'Authorization': f'Bearer {DASHSCOPE_API_KEY}',  # 确保你已经设置了 DASHSCOPE_API_KEY
-    'Content-Type': 'application/json'
-}
-
-data = {
-    "model": "shoemodel-v1",
-    "input": {
-        "template_image_url": "https://infish-oss.oss-cn-beijing.aliyuncs.com/test/model2.jpg",
-        "shoe_image_url": ["https://infish-oss.oss-cn-beijing.aliyuncs.com/test/shoe3.png"]
-    },
-    "parameters": {
-        "n": 1
-    }
-}
-
-task_id = "6488c66d-2a0c-4134-90bb-39ab957d6cdf"
-returl = f'https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}'
-headersret = {
-    'Authorization': f'Bearer {DASHSCOPE_API_KEY}',  # 确保你已经设置了 DASHSCOPE_API_KEY
-}
-# response = requests.post(url, headers=headers, json=data)
-# print(response.json())
-
-response = requests.get(returl, headers=headersret)
+import requests
+
+url = 'https://dashscope.aliyuncs.com/api/v1/services/aigc/virtualmodel/generation/'
+DASHSCOPE_API_KEY = "sk-36a7725c51be4ffe8d3374ea534014b6"
+headers = {
+    'X-DashScope-Async': 'enable',
+    'Authorization': f'Bearer {DASHSCOPE_API_KEY}',  # 确保你已经设置了 DASHSCOPE_API_KEY
+    'Content-Type': 'application/json'
+}
+
+data = {
+    "model": "shoemodel-v1",
+    "input": {
+        "template_image_url": "https://infish-oss.oss-cn-beijing.aliyuncs.com/test/model2.jpg",
+        "shoe_image_url": ["https://infish-oss.oss-cn-beijing.aliyuncs.com/test/shoe3.png"]
+    },
+    "parameters": {
+        "n": 1
+    }
+}
+
+task_id = "6488c66d-2a0c-4134-90bb-39ab957d6cdf"
+returl = f'https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}'
+headersret = {
+    'Authorization': f'Bearer {DASHSCOPE_API_KEY}',  # 确保你已经设置了 DASHSCOPE_API_KEY
+}
+# response = requests.post(url, headers=headers, json=data)
+# print(response.json())
+
+response = requests.get(returl, headers=headersret)
 print(response.json())