The first five minutes, as the product and not as a developer's first run
The first launch was a code box with a link under it, then an empty Live screen with 'No cameras' in amber in a far corner, then a form asking for an IP address, and for the first few minutes of all of it the engine silently downloading 275 MB with nothing on screen but a stopped-looking status. Walked in a browser with the new mock; nobody who was not an installer would have got through it. Now: a welcome that asks the one question a shop owner can answer - managed from a head office, or on this PC only - with each path in a sentence; a Getting Started checklist on Live that reads its three steps from the engine and ticks them itself (recognition ready, camera added and connected, camera proven by a walk-past), with the one button for the next step, and that disappears the moment somebody is recognised; and the model download reported as a percentage in the tray, the sidebar and the checklist, parsed by the supervisor from the engine's own progress lines. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KGcjxF1cNLcuwc3DAPcnfj
This commit is contained in:
@@ -35,6 +35,31 @@ _COPY_MAP = {
|
||||
}
|
||||
|
||||
|
||||
def _fetch(url: str, dest: Path, label: str) -> None:
|
||||
"""Download with progress on stdout the supervisor can read.
|
||||
|
||||
On first run this is minutes of nothing: the API is not up yet, so the
|
||||
app cannot ask the engine what it is doing, and a shop PC that shows a
|
||||
stopped engine for five minutes after install looks broken. The
|
||||
supervisor watches for `download: <label> <n>%` and puts the number in
|
||||
the tray and the window. Logged every 5 points, not every chunk, so the
|
||||
log file does not fill with a progress bar.
|
||||
"""
|
||||
last = -5
|
||||
|
||||
def hook(blocks: int, block_size: int, total: int) -> None:
|
||||
nonlocal last
|
||||
if total <= 0:
|
||||
return
|
||||
pct = min(100, blocks * block_size * 100 // total)
|
||||
if pct >= last + 5:
|
||||
last = pct
|
||||
log.info("download: %s %d%%", label, pct)
|
||||
|
||||
urllib.request.urlretrieve(url, dest, hook)
|
||||
log.info("download: %s 100%%", label)
|
||||
|
||||
|
||||
def setup_models(models_dir: Path) -> "list[str]":
|
||||
"""Ensure all model files exist in models_dir. Returns missing ones."""
|
||||
models_dir = Path(models_dir)
|
||||
@@ -44,7 +69,7 @@ def setup_models(models_dir: Path) -> "list[str]":
|
||||
if not yunet.exists():
|
||||
log.info("downloading YuNet face detector (~230 KB)...")
|
||||
tmp = yunet.with_suffix(".part")
|
||||
urllib.request.urlretrieve(YUNET_URL, tmp)
|
||||
_fetch(YUNET_URL, tmp, "face detector")
|
||||
tmp.rename(yunet)
|
||||
log.info("YuNet saved to %s", yunet)
|
||||
|
||||
@@ -88,7 +113,7 @@ def setup_models(models_dir: Path) -> "list[str]":
|
||||
import zipfile
|
||||
|
||||
tmp = models_dir / "buffalo_l.zip.part"
|
||||
urllib.request.urlretrieve(BUFFALO_L_URL, tmp)
|
||||
_fetch(BUFFALO_L_URL, tmp, "recognition models")
|
||||
with zipfile.ZipFile(tmp) as zf:
|
||||
for name, target in wanted.items():
|
||||
member = next((n for n in zf.namelist()
|
||||
|
||||
Reference in New Issue
Block a user