Rewrite oemer U-Net ConvTranspose pads before packaging.
AppImage release / appimage (push) Successful in 1m42s

ONNX Runtime 1.30+ rejects pads [0, 0, -1, -1] on the unet checkpoint. The build now rewrites those nodes to pads [0, 0, 0, 0] and output_padding [1, 1], which keeps the same output size. Version 0.1.1.
This commit is contained in:
Cursor Agent committed 2026-10-11 07:51:24 +00:00
1 parent ed55f02983
commit 6da116518f
5 files changed
+160 -10

No files matched your search

+36 -3
View File
@@ -7,12 +7,13 @@ ROOT="$(pwd)"
echo "== Install Node packages =="
npm install
mkdir -p "$ROOT/build/cache"
TARBALL="$ROOT/build/cache/cpython.tar.gz"
URL="https://github.com/astral-sh/python-build-standalone/releases/download/20261003/cpython-3.12.15%2B20261003-x86_64-unknown-linux-gnu-install_only.tar.gz"
PY="$ROOT/build/python/bin/python3"
if ! "$PY" -c "import oemer.ete, onnxruntime" >/dev/null 2>&1; then
echo "== Download a relocatable Python and oemer =="
mkdir -p "$ROOT/build/cache"
TARBALL="$ROOT/build/cache/cpython.tar.gz"
URL="https://github.com/astral-sh/python-build-standalone/releases/download/20261003/cpython-3.12.15%2B20261003-x86_64-unknown-linux-gnu-install_only.tar.gz"
if [[ ! -f "$TARBALL" ]]; then
curl -fL --retry 3 -o "$TARBALL" "$URL"
fi
@@ -36,6 +37,38 @@ if [[ ! -f "$SITE/checkpoints/seg_net/model.onnx" ]]; then
curl -fL --retry 3 -o "$SITE/checkpoints/seg_net/model.onnx" \
"https://github.com/BreezeWhite/oemer/releases/download/checkpoints/2nd_model.onnx"
fi
echo "== Rewrite U-Net ConvTranspose pads =="
# oemer 0.1.8's unet has ConvTranspose pads [0, 0, -1, -1]. ONNX Runtime
# 1.30+ rejects those. The rewrite keeps the same output size. onnx itself
# is not packaged.
if ! "$PY" -m pip --version >/dev/null 2>&1; then
if [[ ! -f "$TARBALL" ]]; then
echo "pip was removed and the Python tarball is missing, so the U-Net cannot be rewritten." >&2
exit 1
fi
PIP_RESTORE="$ROOT/build/cache/pip-restore"
rm -rf "$PIP_RESTORE"
mkdir -p "$PIP_RESTORE"
tar -xzf "$TARBALL" -C "$PIP_RESTORE" --wildcards \
'python/lib/python3.12/site-packages/pip' \
'python/lib/python3.12/site-packages/pip-*.dist-info'
rm -rf "$ROOT/build/python/lib/python3.12/site-packages/pip" \
"$ROOT/build/python/lib/python3.12/site-packages/pip-"*.dist-info
cp -a "$PIP_RESTORE/python/lib/python3.12/site-packages/pip" \
"$ROOT/build/python/lib/python3.12/site-packages/"
cp -a "$PIP_RESTORE"/python/lib/python3.12/site-packages/pip-*.dist-info \
"$ROOT/build/python/lib/python3.12/site-packages/"
rm -rf "$PIP_RESTORE"
fi
PATCH_PY="$ROOT/build/cache/onnx-patch"
rm -rf "$PATCH_PY"
"$PY" -m pip install --disable-pip-version-check --target "$PATCH_PY" 'onnx>=1.16,<2'
PYTHONPATH="$PATCH_PY${PYTHONPATH:+:$PYTHONPATH}" \
"$PY" "$ROOT/scripts/patch_oemer_unet.py" \
"$SITE/checkpoints/unet_big/model.onnx"
rm -rf "$PATCH_PY"
MPLBACKEND=Agg "$PY" -c "import oemer.ete, cv2; from cv2.typing import RotatedRect; print('oemer', cv2.__version__)"
echo "== Trim the Python prefix =="