包含: - hair_service_sd: 换发型/换发色算法服务 (端口 8801) - photo_service: LoRA 训练调度服务 (端口 32678) - stable-diffusion-webui: SD WebUI 推理服务 (端口 57860) - kohya_ss_home: 训练环境代码 - meidaojia: 监控测试脚本 - setup.sh: 一键部署脚本 (conda环境恢复 + 配置生成 + 完整性检查) - start_all_services.sh: 启动3个服务 - configure.ini.template: 路径模板化 (BASE_DIR自动推导) - conda_envs/py310.yml: py310 环境定义 大文件 (weights/, models/, data/, conda_envs/*.tar.gz 等) 通过 .gitignore 排除, 由网盘单独上传。
37 lines
1.1 KiB
Python
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() |