初始化:换发型/换发色/训练发型服务
包含: - 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密钥已脱敏为环境变量,原文件备份在本地
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