diff --git a/HAND_AI.md b/HAND_AI.md index f78a431..485b9b5 100644 --- a/HAND_AI.md +++ b/HAND_AI.md @@ -1,5 +1,36 @@ # 区域触发与 D3-lite 步骤确认 +## 2026-11-19:D3-nano 本机试用 + +模型下载到 `E:\D3Nano\model`,固定为 `vllm-sr/d3-nano@8198c9f763b046605b2f4827b4999971fa2c92c4`,从 ModelScope 下载并按 Hugging Face 固定版本校验大小和 LFS SHA-256,加载时执行上游 `verify="full"`。复用 `E:\D3Lite\.venv`,未安装或升级依赖;RTX 4060 Laptop 8GB、BF16 主干、FP32 读出、batch 1、2048 token、上游默认提示和温度,NVIDIA 上未启用上游 fast path。 + +用户授权后短暂停止 D3-lite,以独立端口 8767 测 Nano;测试结束已恢复 `http://127.0.0.1:8766` 的 D3-lite,并更新其 PID/启动时间记录。SOP 界面保留,配方及默认模型配置未改。 + +复用既有 5 张真实相机 JPEG(长边至多 512)和 10 个中英文问题:非空盒、空盒、无手、持物、红蓝物体颜色;输入字节不重编码,响应中的图像 SHA-256 与发送字节逐次核对。两模型各用例先单独记录一次预热,再重复 10 次,共 100 次热态 HTTP 请求。 + +| 本轮结果 | D3-lite | D3-nano | +| --- | ---: | ---: | +| 符合既有用例标签 | 100/100 | 100/100 | +| HTTP 平均 | 86.61ms | 159.30ms | +| P95 | 97.56ms | 171.82ms | +| 最大 | 111.83ms | 175.46ms | +| 低于 500ms | 100/100 | 100/100 | +| 首个图片请求(不计热态统计) | 300.74ms | 284.04ms | +| 中文空盒问题的正例概率(首个热态请求) | 0.7100 | 0.9032 | +| 英文空盒问题的正例概率(首个热态请求) | 0.8489 | 0.9948 | + +Lite 基线服务原先已运行,Nano 为新加载,因此首图耗时不是严格相同冷启动条件的比较。Nano 测前/测后整卡显存为 7137/7167MiB(总 8188MiB,包含桌面与其他程序,非模型独占或峰值)。本轮 HTTP 耗时包含传输及响应解析,不含相机采集和图片准备;重复同一批少量图片不能作为现场准确率估计,概率升高也不表示已完成校准。本轮仅验证现有图片与简单短问题,未验证复杂步骤、持续相机流或其他程序 GPU 竞争时的截止时间。 + +报告保存在工作区 `scratch/test-results/d3-lite-comparison.json`、`scratch/test-results/d3-nano-comparison.json`,日志在 `scratch/logs/`。下载和复测命令(启动 Nano 前需先协调显存及现有服务): + +```powershell +E:\D3Lite\.venv\Scripts\python.exe tools/download_imajev_local.py --root E:\D3Nano --repo vllm-sr/d3-nano --revision 8198c9f763b046605b2f4827b4999971fa2c92c4 --modelscope +E:\D3Lite\.venv\Scripts\python.exe tools/start_d3_lite_local.py --root E:\D3Nano --port 8767 +E:\D3Lite\.venv\Scripts\python.exe tools/benchmark_d3_lite.py --endpoint http://127.0.0.1:8767/v1/systemone --count 10 --output ..\scratch\test-results\d3-nano-comparison.json +``` + +本次将启动器的运行记录改为从安装清单读取真实模型与版本,基准脚本从 `/health` 读取模型名并逐次校验响应模型,避免 Nano 被误标为 Lite;默认路径、端口和判定行为保留。 + 分支:`experiment/hand-motion-ai-decision`。 2026-11-13 第一版已接入 D3-lite:定义区域和步骤 → 配置每步的触发规则和文字完成条件 → 规则满足后取图 → 模型判断 → 完成概率达标后推进。本文后半部分保留此前独立模型测试记录,旧记录中的“未接入 SOP”指当时状态。 diff --git a/tools/benchmark_d3_lite.py b/tools/benchmark_d3_lite.py index 80d2109..738919d 100644 --- a/tools/benchmark_d3_lite.py +++ b/tools/benchmark_d3_lite.py @@ -1,4 +1,4 @@ -"""Compare D3-lite on the existing real camera controls, using ordinary short questions.""" +"""Compare a D3 service on the existing real camera controls, using ordinary short questions.""" import argparse import base64 import hashlib @@ -35,7 +35,7 @@ def post(endpoint, image, question, choices=None, state=""): def stats(runs): values = sorted(row["http_ms"] for row in runs) - return {"count": len(runs), "mean_ms": round(statistics.mean(values), 2), "p95_ms": values[math.ceil(.95 * len(values)) - 1], "max_ms": max(values), "under_200ms": sum(value < 200 for value in values)} + return {"count": len(runs), "mean_ms": round(statistics.mean(values), 2), "p95_ms": values[math.ceil(.95 * len(values)) - 1], "max_ms": max(values), "under_200ms": sum(value < 200 for value in values), "under_500ms": sum(value < 500 for value in values)} def main(): @@ -61,7 +61,10 @@ def main(): ("颜色_中文", "hikvision-imajev-color-20261112-195330-hand-crop-input.jpg", "手里这东西是黄的、绿的,还是红蓝都有?", colors, "有红有蓝"), ("颜色_英文", "hikvision-imajev-color-20261112-195330-hand-crop-input.jpg", "What color is the object held in the hand?", english_colors, "red_and_blue"), ] - report = {"model": "d3-lite", "endpoint": args.endpoint, "scope": "Same real camera images as Imajev, maximum edge 512; one question per request; first call per case recorded separately as warmup", "note": "The upstream D3 response has no automatic abstention/unknown field; confidence is not a correctness guarantee", "cases": []} + health_url = args.endpoint.rsplit("/v1/systemone", 1)[0] + "/health" + with urllib.request.urlopen(health_url, timeout=10) as response: + health = json.load(response) + report = {"model": health["model"], "endpoint": args.endpoint, "health": health, "scope": "Same real camera images as Imajev, maximum edge 512; one question per request; first call per case recorded separately as warmup", "note": "The upstream D3 response has no automatic abstention/unknown field; confidence is not a correctness guarantee", "cases": []} args.output.parent.mkdir(parents=True, exist_ok=True) for name, filename, question, choices, expected in cases: source = images / filename @@ -72,9 +75,11 @@ def main(): row = {"case": name, "input": str(source), "image_size": size, "image_sha256": hashlib.sha256(data).hexdigest(), "question": question, "choices": choices, "expected": expected, "runs": []} row["warmup"] = post(args.endpoint, data, question, choices) + assert row["warmup"]["response"]["model"] == report["model"], "Served model changed during benchmark" report["cases"].append(row) for _ in range(args.count): run = post(args.endpoint, data, question, choices) + assert run["response"]["model"] == report["model"], "Served model changed during benchmark" run["correct"] = run["actual"] == expected row["runs"].append(run) args.output.write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding="utf-8") diff --git a/tools/start_d3_lite_local.py b/tools/start_d3_lite_local.py index f38ecf5..f1e389d 100644 --- a/tools/start_d3_lite_local.py +++ b/tools/start_d3_lite_local.py @@ -1,4 +1,4 @@ -"""Serve a verified local D3-lite package; keep upstream prompts, attention and answer mapping.""" +"""Serve a verified local D3 package; keep upstream prompts, attention and answer mapping.""" import argparse import base64 import hashlib @@ -38,10 +38,13 @@ def main(): raise RuntimeError(f"Vision failed to initialize: {model.image_unavailable}") # The stock warmup also runs four 1.6MP images. This test uses one 512px image on an 8GB GPU. model.warmup(lengths=(64, 384), images=False) - settings = {"repo": "vllm-sr/d3-lite", "revision": "6c01fba14e74f63b70e1ef442b0b6d1b934339d5", + manifest = json.loads((root / "local-model-manifest.json").read_text(encoding="utf-8")) + provenance = model.provenance() + package = next(entry for entry in manifest if entry["repo"] == provenance["repo_id"]) + settings = {"repo": package["repo"], "revision": package["revision"], "device": torch.cuda.get_device_name(), "torch": torch.__version__, "transformers": transformers.__version__, "runtime": model.runtime_info(), - "provenance": model.provenance()} + "provenance": provenance} (root / "local-serving-settings.json").write_text(json.dumps(settings, indent=2, default=str), encoding="utf-8") class TracedDecider(Decider):