Files
xsl 443cfa298f 初始化:换发型/换发色/训练发型服务
包含:
- hair_service_sd: 主服务(换发型/换发色/生发,端口8801)
- photo_service: LoRA调度+训练(端口32678)
- hair_grow_service: 调试测试页(端口8888,含4个测试页)
- 批量训练脚本(batch_train_hairstyles.py)
- 发际线mask自动识别(hairline_mask.py,4种方案)
- 手绘mask换发型(hair_swap_manual.py)
- 文档:README.md + LARGE_FILES.md + docs/

大文件(模型权重200G、训练数据123G)已排除,见 LARGE_FILES.md
OSS/COS密钥已脱敏为环境变量,原文件备份在本地
2026-07-07 13:53:52 +08:00

37 lines
1.1 KiB
Python

import requests
import cv2
import numpy as np
import base64
import sys
import json
if __name__ == '__main__':
path = './data/template01.png'
img = cv2.imread(path)
retval, bytes = cv2.imencode('.jpg', img)
encoded_image = base64.b64encode(bytes).decode('utf-8')
user_id = '61AB9097'
#给api_service.py发送请求
url = "http://i-2.gpushare.com:53412/user/generate"
payload = json.dumps({
"user_id": "61AB9097",
"base_img": encoded_image
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
if response.status_code != 200:
raise RuntimeError(f"Failed to send request to API service. Status code: {response.status_code}")
ret_image_b64 = response.json().get('generate_photo_b64')
if ret_image_b64 is None:
raise RuntimeError(f"ret image failed!")
image_array = np.frombuffer(base64.b64decode(ret_image_b64), np.uint8)
image = cv2.imdecode(image_array, cv2.IMREAD_COLOR)
cv2.imshow('image', cv2.resize(image, (0, 0), fx=0.5, fy=0.5))
cv2.waitKey()