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:
+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}"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user