包含: - 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密钥已脱敏为环境变量,原文件备份在本地
25 lines
922 B
Python
25 lines
922 B
Python
from seg.hairseg_single_model import Evaluator
|
|
import os
|
|
import cv2
|
|
import numpy as np
|
|
if __name__ == "__main__":
|
|
|
|
data_path = "/home/liyang/project/matting/合格/origin"
|
|
dst_path = "/home/liyang/project/matting/合格/origin_seg_res1102"
|
|
if not os.path.exists(dst_path):
|
|
os.mkdir(dst_path)
|
|
seg_model = Evaluator(gpu_id=0, output_img_size=512, nclass=3)
|
|
for imgs in os.listdir(data_path):
|
|
if imgs.endswith(".txt"):
|
|
continue
|
|
|
|
img_path = os.path.join(data_path, imgs)
|
|
img = cv2.imread(img_path)
|
|
if img_path.endswith('.png'):
|
|
kpts_1k = np.loadtxt(img_path.replace('.png', '_landmark1k.txt'))
|
|
elif img_path.endswith('.jpg'):
|
|
kpts_1k = np.loadtxt(img_path.replace('.jpg', '_landmark1k.txt'))
|
|
output_img_size = 512
|
|
mask = seg_model.eval(img, kpts_1k)
|
|
cv2.imwrite(os.path.join(dst_path, imgs), mask)
|