初始化换发型项目: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:
@@ -0,0 +1,125 @@
|
||||
import requests
|
||||
import json
|
||||
from common.logger import config
|
||||
|
||||
version = config.get('default', 'version')
|
||||
if version == "local":
|
||||
current_photo_service_url = 'http://192.168.1.57:32678/'
|
||||
else:
|
||||
current_photo_service_url = 'http://0.0.0.0:32678/'
|
||||
|
||||
def call_hair_infer(task_id, hair_id, hair_material_dir, infer_req, is_hr, inference_port):
|
||||
url = f"{current_photo_service_url}api/hair/inference"
|
||||
payload = json.dumps({
|
||||
"task_id": task_id,
|
||||
"hair_id": hair_id,
|
||||
"hd_version_flag":is_hr,
|
||||
"hair_material_dir": hair_material_dir,
|
||||
"request_json": infer_req,
|
||||
"inference_port": inference_port
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
# print("---call infer payload:", payload)
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
# print(response.json())
|
||||
|
||||
return response.json()
|
||||
|
||||
def call_hair_infer_diy(task_id, infer_req, inference_port):
|
||||
url = f"{current_photo_service_url}api/hair/inference_diy"
|
||||
payload = json.dumps({
|
||||
"task_id": task_id,
|
||||
"request_json": infer_req,
|
||||
"inference_port": inference_port
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
# print("---call infer payload:", payload)
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
# print(response.json())
|
||||
|
||||
return response.json()
|
||||
|
||||
|
||||
|
||||
def call_hair_enhance(img_path, mask_path, task_id, in_gender):
|
||||
url = "http://127.0.0.1:7393/hairEnhance/v1"
|
||||
payload = json.dumps({
|
||||
"img_path": img_path,
|
||||
"mask_path": mask_path,
|
||||
"req_id": task_id,
|
||||
"gender": in_gender
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
# print("---call infer payload:", payload)
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
# print(response.json())
|
||||
|
||||
return response.json()
|
||||
|
||||
def face_info(img_path):
|
||||
url = "http://127.0.0.1:7393/faceInfo/v1"
|
||||
payload = json.dumps({
|
||||
"img": img_path,
|
||||
"userId": 'fff',
|
||||
"isLocal": True,
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
# print("---call infer payload:", payload)
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.json())
|
||||
|
||||
return response.json()
|
||||
|
||||
def is_same(img_url1, img_url2):
|
||||
url = "http://127.0.0.1:7393/faceInfo/same"
|
||||
payload = json.dumps({
|
||||
"img_url1": img_url1,
|
||||
"img_url2": img_url2,
|
||||
# "isLocal": True,
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
# print("---call infer payload:", payload)
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.json())
|
||||
|
||||
return response.json()
|
||||
|
||||
def hair_select(img_url):
|
||||
url = "http://127.0.0.1:7393/hairStyle/hair_select"
|
||||
payload = json.dumps({
|
||||
"img_url": img_url,
|
||||
# "isLocal": True,
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
# print("---call infer payload:", payload)
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.json())
|
||||
|
||||
return response.json()
|
||||
# test_url = 'https://ydapp-1317132355.cos.ap-beijing.myqcloud.com/hair_mz/images/hairstyle/fb7d7a58-3228-40f2-84a6-337088ee31e2/2023031623425988.jpg'
|
||||
# test_url = 'https://ydapp-1317132355.cos.ap-beijing.myqcloud.com/hair_mz/images/vaffflue12.png'
|
||||
# hair_select(test_url)
|
||||
Reference in New Issue
Block a user