Best was a mixture of two experts and a gate, 110 GMAC a megapixel; Medium a single network at 48 that was softer on real edges. fb-combo (darkroom-denoise, 20 000 steps from fb-edges2, taught by the mixture with a quarter of its crops from the edge-rich parts of the frames) is Medium's shape and holds the mixture's edges on real photographs: edge PSNR within 0.04-0.06 dB at ISO 1600/6400/25600, more sharpness kept at all three, the chart's edge 0.89 photosites wide against 0.82. It is 0.27 dB short on smooth areas at ISO 25600. It becomes Best, and the methods are Bilinear, Fast and Best. Saved edits keep their numbers: 2, which was Medium, is now Best, and 3, which was Best, is past the end and reads as the default, Best. The network ships as mosaic-hq, a new name: the result cache keys a model by name and size, and this one is byte for byte the old Medium's size. Its tablet form (A16W16) lost 0.00 dB in simulated QDQ at every ISO and at most 0.09 dB across the noise bracket.
40 lines
1.8 KiB
Bash
Executable File
40 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Produce the Hexagon's form of each model (docs/dev/inference.md §1.5, §5).
|
|
#
|
|
# ./tools/quantise-models.sh PHOTO_DIR [MODEL ...]
|
|
# ./tools/quantise-models.sh --ranges RANGES.json mosaic-hq-1408
|
|
#
|
|
# Writes `<stem>.<form>.onnx` beside each canonical file under models/: a QDQ
|
|
# graph from QNN's own quantisation config, per-channel weights, in the form
|
|
# the engine's `Rung::form` names for that role — A16W8, A16W16 or int8, each
|
|
# the narrowest that held the model's accuracy on the tablet. The activation
|
|
# ranges come from running the f32 model over the photographs in PHOTO_DIR,
|
|
# fed exactly as the app feeds them (letterbox maths, pads, normalisation,
|
|
# face crops through the app's own similarity), which is why this is a
|
|
# release-time step and not something the device does. With no MODEL, every
|
|
# model in the table.
|
|
#
|
|
# The denoiser is calibrated on noisy mosaics, not photographs: its ranges
|
|
# come from darkroom-denoise's precision gate (`--ranges`), computed on a
|
|
# smaller tile of the same network — activation ranges do not depend on the
|
|
# tile's size, and the tensor names match.
|
|
#
|
|
# Then measure before shipping: a quantised form is a different network, and
|
|
# the numbers in inference.md §1.5 are what each one had to hold.
|
|
#
|
|
# A venv per run, like fix-face-model-shapes.sh: the tools are not a build
|
|
# input and nothing in the tree should have them on its path.
|
|
set -euo pipefail
|
|
if [ "$#" -lt 1 ]; then
|
|
sed -n '2,27p' "$0" >&2
|
|
exit 2
|
|
fi
|
|
|
|
WORK="$(mktemp -d -p /var/tmp quantise-models.XXXXXX)"
|
|
trap 'rm -rf "${WORK}"' EXIT
|
|
echo "==> venv in ${WORK}"
|
|
uv venv --python 3.12 "${WORK}/venv" >/dev/null
|
|
VIRTUAL_ENV="${WORK}/venv" uv pip install --quiet onnx onnxruntime pillow numpy sympy
|
|
|
|
exec "${WORK}/venv/bin/python" "$(dirname "$0")/quantise-models.py" "$@"
|