初始化换发型项目:3个微服务代码 + 部署脚本

包含:
- 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 排除,
由网盘单独上传。
This commit is contained in:
colomi
2026-07-11 18:11:49 +08:00
commit 0eb61f3e60
628 changed files with 120882 additions and 0 deletions
+126
View File
@@ -0,0 +1,126 @@
import threading
import requests
import json
import base64
url = 'http://mq.aidigifi.meidaojia.com/api/swapHair/v1'
# url = 'https://692139771842565-http-8801.northwest1.gpugeek.com:8443/api/swapHair/v1'
headers = {'Content-Type': 'application/json'}
data = {
"hair_id": "1907651680352395265",
"task_id": "1907651680352395265",
"user_img_path": "https://cdn.meidaojia.com/ZoeFiles/user2_1_%E5%89%AF%E6%9C%AC.JPG",
# "user_img_path": "https://cdn.meidaojia.com/ZoeFiles/testuser_8.JPG",
"is_hr": "false",
"output_format": "base64"
}
more_data = []
more_data.append(data)
data1 = {
"hair_id": "1907651680352395265",
"task_id": "2345623451234",
"user_img_path": "https://cdn.meidaojia.com/ZoeFiles/testuser_8.JPG",
"is_hr": "false",
"output_format": "base64"
}
more_data.append(data1)
data2 = {
"hair_id": "1907651680352395265",
"task_id": "3145645324",
"user_img_path": "https://cdn.meidaojia.com/ZoeFiles/testuser_7.JPG",
"is_hr": "false",
"output_format": "base64"
}
more_data.append(data2)
data3 = {
"hair_id": "1907651680352395265",
"task_id": "456412345",
"user_img_path": "https://cdn.meidaojia.com/ZoeFiles/testuser_6.JPG",
"is_hr": "false",
"output_format": "base64"
}
more_data.append(data3)
data4 = {
"hair_id": "1907651680352395265",
"task_id": "45623445",
"user_img_path": "https://cdn.meidaojia.com/ZoeFiles/testuser_5.JPG",
"is_hr": "false",
"output_format": "base64"
}
more_data.append(data4)
data5 = {
"hair_id": "1907651680352395265",
"task_id": "2345867435",
"user_img_path": "https://cdn.meidaojia.com/ZoeFiles/testuser_4.JPG",
"is_hr": "false",
"output_format": "base64"
}
more_data.append(data5)
data6 = {
"hair_id": "1907651680352395265",
"task_id": "86747535",
"user_img_path": "https://cdn.meidaojia.com/ZoeFiles/testuser_3.JPG",
"is_hr": "false",
"output_format": "base64"
}
more_data.append(data6)
def image_to_base64(image_path):
"""读取图片文件并转换为Base64编码"""
with open(image_path, "rb") as image_file:
# 读取图片二进制数据
image_data = image_file.read()
# 转换为Base64编码的bytes
base64_bytes = base64.b64encode(image_data)
# 转换为字符串(如果需要)
base64_string = base64_bytes.decode('utf-8')
return base64_string
# img64_str = image_to_base64("test_image.jfif")
# data['user_img_path'] = img64_str
# 存储所有请求的响应
responses = []
# 线程锁,防止多线程写入冲突
lock = threading.Lock()
send_index = 0
def send_request():
try:
global send_index
send_data = more_data[send_index]
send_index = send_index + 1
response = requests.post(url, headers=headers, json=send_data)
with lock: # 加锁,防止多线程同时修改 responses
responses.append(response.json())
except Exception as e:
with lock:
responses.append({"error": str(e)})
# 创建并启动多个线程
threads = []
num_requests = 7 # 并发请求数量
for _ in range(num_requests):
t = threading.Thread(target=send_request)
t.start()
threads.append(t)
# 等待所有线程完成
for t in threads:
t.join()
# 打印所有响应
for i, resp in enumerate(responses, 1):
print(f"请求 {i} 结果:", resp)