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:
@@ -58,8 +58,6 @@ local_test/hair_service.pid
|
||||
benchmark_out/
|
||||
|
||||
# benchmark 部署的 HTML 报告(图片 base64 内嵌,体积大,不入 git)
|
||||
static/benchmark_report.html
|
||||
static/hairstyle_report.html
|
||||
static/hairstyle_thumbs/
|
||||
|
||||
# 网关运行期日志(不入 git)
|
||||
|
||||
@@ -14,11 +14,19 @@ RESULTS = OUT / "results.json"
|
||||
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):
|
||||
return None
|
||||
with open(path, "rb") as f:
|
||||
return f"data:image/jpeg;base64,{base64.b64encode(f.read()).decode()}"
|
||||
from io import BytesIO
|
||||
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():
|
||||
|
||||
+11
-4
@@ -23,12 +23,19 @@ MODEL_LABEL = {
|
||||
MODEL_ORDER = ["4b-fp8", "9b-Q4", "9b-Q5", "9b-fp8"]
|
||||
|
||||
|
||||
def img_b64(path, max_w=240):
|
||||
"""读图片转 base64 data URI。"""
|
||||
def img_b64(path, max_w=320, quality=72):
|
||||
"""读图片,缩放到 max_w 宽、JPEG 降质后转 base64 data URI(压缩体积便于入 git)。"""
|
||||
if not path or not os.path.isfile(path):
|
||||
return None
|
||||
with open(path, "rb") as f:
|
||||
b = base64.b64encode(f.read()).decode()
|
||||
from io import BytesIO
|
||||
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}"
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user