# PLT 裁片处理微服务 独立的 PLT 文件处理服务,可部署到阿里云 SAE。 ## 本地运行 ```bash # 安装依赖 pip install -r requirements.txt # 启动服务 python main.py ``` 服务启动后访问:http://localhost:8080 ## Docker 构建 ```bash # 构建镜像 docker build -t plt-service:latest . # 运行容器 docker run -p 8080:8080 plt-service:latest ``` ## 部署到阿里云 SAE ### 1. 构建并推送镜像到阿里云容器镜像服务 ```bash # 登录阿里云容器镜像服务 docker login --username=<你的阿里云账号> registry.cn-hangzhou.aliyuncs.com # 构建镜像 docker build -t registry.cn-hangzhou.aliyuncs.com/<命名空间>/plt-service:v1.0 . # 推送镜像 docker push registry.cn-hangzhou.aliyuncs.com/<命名空间>/plt-service:v1.0 ``` ### 2. 在 SAE 创建应用 1. 进入阿里云 SAE 控制台 2. 创建应用 → 选择"镜像部署" 3. 填写镜像地址:`registry.cn-hangzhou.aliyuncs.com/<命名空间>/plt-service:v1.0` 4. 配置规格: - CPU: 2核 - 内存: 4GB - 最小实例数: 0(无请求时不收费) - 最大实例数: 5 5. 完成创建 ### 3. 配置公网访问 在 SAE 应用详情 → 基本信息 → SLB 设置 → 添加公网 SLB ## API 接口 ### 健康检查 ``` GET /health ``` ### 处理 PLT 文件 ``` POST /process Content-Type: multipart/form-data 参数: - file: PLT 文件 - size_labels: 尺码标签,如 ["S","M","L","XL","2XL"] - dpi: 输出分辨率(默认 150) - rotation: 旋转角度(0/90/-90/180) ``` 响应示例: ```json { "success": true, "total_groups": 5, "groups": [ { "group_id": 1, "pieces": [ { "size": "S", "image_base64": "data:image/png;base64,...", "width_px": 500, "height_px": 300, "width_cm": 25.5, "height_cm": 15.3, "center_x_cm": 12.75, "center_y_cm": 7.65, "left_cm": 0, "top_cm": 0 } ] } ] } ``` ## 费用估算(阿里云 SAE) | 场景 | 费用 | |------|------| | 处理 1 个 PLT(30秒) | ¥0.04 | | 每天 100 个 PLT | ¥4/天 | | 无请求时 | ¥0(最小实例设为0) |