Skip to content

Add standalone Python 3 / TF 2.15 port (no ROS) + fixed stale weights download URL - #8

Open
timotizianomeier wants to merge 4 commits into
LCAS:masterfrom
timotizianomeier:pr/python3-port
Open

timotizianomeier wants to merge 4 commits into
LCAS:masterfrom
timotizianomeier:pr/python3-port

Conversation

@timotizianomeier

Copy link
Copy Markdown

Hi Francesco, following up on our email exchange, this is the Python 3 port I mentioned. Four commits, in three independent parts:

  1. download_model.sh: point at the canonical Nextcloud URL. The old owncloud link still resolves, but only via a 301+302 redirect chain; this links directly to the current canonical location. Verified (HTTP 200, content-length matches the published .h5).
  2. standalone_demo/: a self-contained, ROS-free Python 3 port of the detector (Python 3.11, TF 2.15 — the last Keras-2 release, so the pretrained LSTM loads unchanged; ResNeXt50 revived via the archived keras-applications package). Includes a live webcam demo and pinned requirements. Verified equivalent to the original pipeline: same preprocessing, same feature shapes, weights load without custom objects. Tested on Apple Silicon macOS; Linux needs the one-line tensorflow-macos -> tensorflow swap noted in the README.
  3. A minimal localhost HTTP service exposing the detector (POST /score: 10 base64 JPEG frames -> engagement float), for consuming it from environments that can't share its Python version. Stdlib only. A regression test proves the HTTP score equals direct predict() (diff < 1e-7) and covers the error paths. A --host flag (default 127.0.0.1) allows serving clients on other machines, e.g. a robot.

The original ROS package is untouched, everything lives alongside it. Happy to restructure (different folder name, drop the service, squash) or split this into separate PRs, whatever suits the repo. And absolutely fine if you'd rather keep upstream as-is, the fork serves my needs either way.

Context: I'm using this model (via your 2020 paper) in my MSc thesis on a socially assistive robot for students with ADHD at Imperial College London.

Modernised, ROS-free port of the engagement detector so it runs on current systems (tested: Apple Silicon, Python 3.11, tensorflow-macos 2.15, the last Keras-2 release). ResNeXt50 comes from the archived keras-applications package; the pretrained LSTM h5 loads unchanged. Includes a live webcam demo and pinned requirements. Verified against the original pipeline: same preprocessing, same feature shapes, pretrained weights load without custom objects.
Wraps EngagementDetector behind POST /score (10 base64 JPEG frames -> engagement float) and GET /health on 127.0.0.1:8100, so apps in other Python environments can consume scores across the process boundary. Frames decode via cv2.imdecode (BGR), matching the validated webcam path. Loads models before binding; refuses stand-in weights unless --allow-standin. Round-trip test proves HTTP score equals direct predict (diff <1e-7) and covers the 400/404 error paths.
@timotizianomeier
timotizianomeier marked this pull request as ready for review August 25, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant