# Palm Line Reader

- Source: <https://github.com/samuelwbarber/palm-line-reader>
- Pinned revision: `bc48939f4deee6d8ff842bfde499396dab9c4830`
- Verified: 2026-10-21
- License declaration: repository-level MIT, Copyright (c) 2026 Sam Barber. Preserved in `LICENSE` and `/licenses/palm-line-reader-MIT.txt`.
- Source file: `web/palmLines.js`; original SHA-256 `735101ba790c62ec7798764c92e5deb00243dfef1c1ef183efaca02b47f63037`.

## Local modifications

The preprocessing constants, 512 × 512 plain resize, RGB ImageNet normalization and four-class argmax are unchanged. The host passes verified model bytes instead of an external model URL. Local changes add input/output tensor disposal, finite/output-shape validation and clearing of the temporary image canvas and normalized input after inference. The host adapter adds conservative foreground, continuity and input-contrast display checks. These checks are **not** a calibrated confidence score or a hand detector.

## Model and dataset provenance

`models/student_fp16.onnx` is distributed in the pinned repository under its repository-level MIT declaration. The repository does not include a separate model license, model card or an attestation of commercial rights for all training images. Its README says the RGB training examples were scraped from Reddit `r/PalmReading`, pseudo-labelled with a teacher network, then reviewed. The scraped original photos and teacher checkpoint are not distributed. The encoder is described as `mit_b0` in a `segmentation_models_pytorch` UNet. These are upstream statements, not a separately audited chain of rights. Commercial training-data rights remain unverified.

The model and runtime files are pinned by size and SHA-256 in `/palm/manifest.json`. Browser initialization also verifies the downloaded model and WASM bytes; the runtime script uses SRI. No upstream sample photo is redistributed as a public product asset.

## Runtime and privacy boundary

Runtime: official `onnxruntime-web` npm package **1.20.1**, WASM-only build. MIT notice and the official v1.20.1 third-party notices are preserved under `/licenses/palm-onnxruntime-*`. No install scripts or upstream Python training code are executed.

All runtime/model URLs are same-origin `/palm/` assets. One WASM thread, `proxy = false`, no blob worker, camera stream, image upload, telemetry call, persistence or external inference endpoint. Initialization happens only when the UI explicitly calls `createPalmEngine` after Analyze. The line model's own first uncached download is 22.6 MB decimal; together with the hand-landmark tool below, one first analysis downloads about 41.9 MB. The caller owns crop orientation; right-hand crops must be mirrored for this left-palm model. Since 2026-10-29 the page decides mirroring from hand landmarks when they are found and falls back to the user's left/right choice.

`AbortSignal` cancels downloads and discards results; browser WASM inference/session construction already in progress cannot be interrupted. Late-created sessions are released. The UI must also ignore stale request generations and dispose the returned engine. Lack of detections must remain an insufficient/retry state, never generated lines or an unconditional reading.

## Hand landmarks (added 2026-10-29)

- Package: `@mediapipe/tasks-vision` **0.10.35** (npm, published 2026-04-27), Apache-2.0. Tarball `https://registry.npmjs.org/@mediapipe/tasks-vision/-/tasks-vision-0.10.35.tgz`, integrity `sha512-HOvadwVRE6JC+45nyYhmnywnr5h/J8KZvOeUNVOG9q/0875pZgItznFB9bRTvLc264YSJqiZ1NsIpCStJw/egg==` (verified against the downloaded file). License text from the matching `google-ai-edge/mediapipe` tag `v0.10.35` is kept in `/licenses/palm-mediapipe-Apache-2.0.txt`.
- Why this version: 1.x releases (from 2026-07) send MediaPipe usage metrics to `https://odml.pa.googleapis.com/v1/log` and ask apps to obtain user consent. 0.10.35's JS bundle and WASM loader contain no such endpoint; the only network use is loading the files handed to it. A real-browser run of the page recorded zero cross-origin requests.
- Model: `hand_landmarker.task` float16 v1 from `storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/`, 7,819,105 bytes. Google's model card "Hand Tracking (Lite/Full) with Fairness, Oct 2021" states Apache License 2.0.
- Served files: `/palm/hands/vision_wasm_internal.js` and `.wasm` (SIMD build only) and `/palm/models/hand_landmarker.task`. Each is fetched same-origin, checked by size and SHA-256, then given to MediaPipe as a `blob:` URL or byte buffer so it cannot load a different file. CPU delegate, IMAGE mode, one hand.
- Local modification: the bundled `vision_bundle.mjs` (original SHA-256 `55d7ab624fbb70dcc5adc4ae6d7ea9cfcb569139d3dbfbf2b1deafcb966bc0fe`) has `webpackIgnore`/`turbopackIgnore` comments added to its single variable `import()` (a worker-only fallback) so the Next build can bundle it. No logic changed.
- Use: 21 landmarks give the hand's own coordinate frame. They place mount areas, measure palm/finger proportions and tell which way the palm faces. They are never drawn as palm lines. Mount prominence cannot be measured from a photo and is not judged.

## Minor lines

Fate, sun, marriage and travel lines are found by a local ridge (crease) filter inside hand-relative zones, not by a trained model. They appear only when a ridge is actually found and are read only after the user confirms each one. Children lines are not read.
