product-recognition-demo/recognization/run-demo-server.sh
kiyo9w 0e23425ef0 feat: a live path that uses the enrolled store, and a demo server a phone can reach
The live session scored crops with the matcher regardless of the configured identity
backend, so a live scan used the old mechanism while the still path used the enrolled
gallery - measured, the matcher accepts look-alikes and cannot say "unknown", which is
exactly what a real shelf needs it to do. score_crop now routes to the gallery, and
the decision uses a similarity scale (accept at 0.60 with a 0.04 margin) rather than
inlier-count thresholds that mean nothing on a cosine.

The synthetic walk is gone: demo.py, demo_replay.py, the /v1/demo endpoints and the
walk benchmark are deleted, and the app's frame source is the camera on a device (the
single-image replay stays for the simulator, which has no camera).

stock-demo merges both demo shelves (27 products, 62 views, trained head) so one
server recognises either image, and run-demo-server.sh starts it bound to 0.0.0.0 and
prints the exact URL to put in Config.xcconfig.

Verified over the LAN with 1280x960 frames: 40 frames in 5.3s, 9 products recognised
on demo image 1.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-25 10:51:57 +09:00

45 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# The demo server: one command, bound to the network so a phone can reach it.
#
# ./run-demo-server.sh # both demo shelves enrolled (stock-demo)
# ./run-demo-server.sh stock-milk150
#
# The iPhone must be on the same Wi-Fi as this Mac, and the app must point at this
# Mac's address - Config.xcconfig's APP_RECOGNITION_BASE_URL, which the app reads at
# build time. The script prints the exact line to use.
set -euo pipefail
cd "$(dirname "$0")"
STOCK="${1:-stock-demo}"
PORT="${PORT:-8099}"
if [ ! -d "$STOCK" ]; then
echo "no such store: $STOCK" >&2
exit 1
fi
IP="$(ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1 2>/dev/null || true)"
if [ -z "$IP" ]; then
echo "this Mac has no LAN address; the phone cannot reach it" >&2
exit 1
fi
cat <<EOF
Dorayaki demo server
store $STOCK ($(ls "$STOCK" | grep -c -E '\.(jpeg|jpg|png)$') enrolled views)
listening http://0.0.0.0:$PORT
phone URL http://$IP:$PORT
Put this in iosApp/Configuration/Config.xcconfig and rebuild the app:
APP_RECOGNITION_BASE_URL = http:/\$()/$IP:$PORT
Health check from another device: http://$IP:$PORT/v1/health
EOF
# A phone on the same Wi-Fi reaches 0.0.0.0; localhost-only would not.
exec env YOLO_OFFLINE=1 DORAYAKI_STOCK_DIR="$STOCK" \
.venv/bin/python -u code/app.py \
--port "$PORT" --host 0.0.0.0 --identity gallery \
--live-conf 0.25 --classify-workers 8