#!/usr/bin/env bash # Fetch the JPEG-AI whole-decoder test inputs from WAI's content-versioned models # root and check every byte against the SHA-256 manifest committed next to this # script (tools/jpegai-e2e-v1.sha256). # # tools/wai_jpegai_fetch_e2e_inputs.sh [out-dir] # default /tmp/jpegai_e2e # # Then run the tests that read them (tests/jpegai_e2e_full.rs, # tests/jpegai_reconstruction_binding.rs) with # WAI_JPEGAI_CODESTREAM=/test256.bin # WAI_JPEGAI_WEIGHTS_DIR= # WAI_JPEGAI_NORM=/norm.json # # What is fetched: the eleven integer/PTQ weight files the decoder runs # ({hs,hyp,synth}_{y,uv}.json, mcm{0..3}_y.json, icci.json), norm.json (normative # tables plus the reference decoder's RGB output for the test picture) and # test256.bin (the test codestream). They were extracted by # tools/wai_jpegai_build_e2e_inputs.py from the JPEG-AI reference-software assets, # which are not in this repository; the models root publishes the extraction under # an immutable versioned path (jpegai/v1/). The manifest pins those exact bytes, so # a changed or truncated file at the URL fails here instead of changing what the # tests check. # # WAI_JPEGAI_INPUTS_URL overrides the base URL (a mirror holding the same files). set -euo pipefail here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" manifest="$here/jpegai-e2e-v1.sha256" base="${WAI_JPEGAI_INPUTS_URL:-https://wai.transaction.science/models/jpegai/v1}" out="${1:-/tmp/jpegai_e2e}" mkdir -p "$out" out="$(cd "$out" && pwd)" if command -v sha256sum >/dev/null 2>&1; then sha() { sha256sum "$@"; } else sha() { shasum -a 256 "$@"; } fi while read -r want name; do [ -n "$name" ] || continue curl --proto '=https' --tlsv1.2 -fsSL --retry 3 -o "$out/$name.part" "$base/$name" got="$(sha "$out/$name.part" | cut -d' ' -f1)" if [ "$got" != "$want" ]; then echo "error: $base/$name has sha256 $got, pinned $want" >&2 rm -f "$out/$name.part" exit 1 fi mv "$out/$name.part" "$out/$name" echo "ok $want $name" done < "$manifest" echo "JPEG-AI e2e inputs verified in $out"