docs: 添加模型对比/发型对比 HTML 测试报告

报告图片已压缩为内嵌 JPG(缩放至300px宽,质量70),体积从 ~45MB 降至 ~3MB:
- static/benchmark_report.html: 4模型×3分辨率矩阵对比 (2.7MB)
- static/hairstyle_report.html: 3图×5发型×10组合对比 (3.1MB)

同步更新报告生成脚本支持图片压缩,并从 .gitignore 移除报告文件排除。
This commit is contained in:
xsl
2026-07-25 16:17:14 +08:00
parent 94cdfd6de5
commit ab6b0cb0bb
5 changed files with 290 additions and 9 deletions
-2
View File
@@ -58,8 +58,6 @@ local_test/hair_service.pid
benchmark_out/ benchmark_out/
# benchmark 部署的 HTML 报告(图片 base64 内嵌,体积大,不入 git) # benchmark 部署的 HTML 报告(图片 base64 内嵌,体积大,不入 git)
static/benchmark_report.html
static/hairstyle_report.html
static/hairstyle_thumbs/ static/hairstyle_thumbs/
# 网关运行期日志(不入 git # 网关运行期日志(不入 git
+11 -3
View File
@@ -14,11 +14,19 @@ RESULTS = OUT / "results.json"
HTML = OUT / "report.html" HTML = OUT / "report.html"
def img_b64(path): def img_b64(path, max_w=300, quality=70):
"""读图片,缩放到 max_w 宽、JPEG 降质后转 base64 data URI(压缩体积便于入 git)。"""
if not path or not os.path.isfile(path): if not path or not os.path.isfile(path):
return None return None
with open(path, "rb") as f: from io import BytesIO
return f"data:image/jpeg;base64,{base64.b64encode(f.read()).decode()}" from PIL import Image
im = Image.open(path).convert("RGB")
if im.width > max_w:
nh = round(im.height * max_w / im.width)
im = im.resize((max_w, nh), Image.LANCZOS)
buf = BytesIO()
im.save(buf, format="JPEG", quality=quality, optimize=True)
return f"data:image/jpeg;base64,{base64.b64encode(buf.getvalue()).decode()}"
def main(): def main():
+11 -4
View File
@@ -23,12 +23,19 @@ MODEL_LABEL = {
MODEL_ORDER = ["4b-fp8", "9b-Q4", "9b-Q5", "9b-fp8"] MODEL_ORDER = ["4b-fp8", "9b-Q4", "9b-Q5", "9b-fp8"]
def img_b64(path, max_w=240): def img_b64(path, max_w=320, quality=72):
"""读图片转 base64 data URI。""" """读图片,缩放到 max_w 宽、JPEG 降质后转 base64 data URI(压缩体积便于入 git"""
if not path or not os.path.isfile(path): if not path or not os.path.isfile(path):
return None return None
with open(path, "rb") as f: from io import BytesIO
b = base64.b64encode(f.read()).decode() from PIL import Image
im = Image.open(path).convert("RGB")
if im.width > max_w:
nh = round(im.height * max_w / im.width)
im = im.resize((max_w, nh), Image.LANCZOS)
buf = BytesIO()
im.save(buf, format="JPEG", quality=quality, optimize=True)
b = base64.b64encode(buf.getvalue()).decode()
return f"data:image/jpeg;base64,{b}" return f"data:image/jpeg;base64,{b}"
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long