Let the segmentation export script pick its own input size
Comparing a larger model against a larger input size meant re-exporting at resolutions other than the shipped 640, and the script only ever wrote that one number. `IMGSZ` is now a second positional argument, defaulted to 640 so every existing call is unchanged. The experiment this was built for found bigger input a net loss on its own merits — yolo26n-seg and yolo26s-seg at 1280 both lost track of large, frame-filling subjects (a bus's box shrank and its score nearly halved) in exchange for catching small or partially-occluded ones tiling already handles. Nothing shipped from it, but the ability to re-run that comparison is worth keeping. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
# (see the workspace manifest for why that backend was chosen), and it is what
|
||||
# makes the tiling option in `semantic.rs` the only route to more resolution.
|
||||
#
|
||||
# `imgsz=640` square rather than a rectangle matched to 3:2: one graph has to
|
||||
# `imgsz` square rather than a rectangle matched to 3:2: one graph has to
|
||||
# serve portrait, landscape, square crops and panoramas. A landscape-shaped
|
||||
# graph trades letterbox waste on 3:2 for worse waste on everything else.
|
||||
set -euo pipefail
|
||||
@@ -27,21 +27,23 @@ REPO="$(cd "${HERE}/.." && pwd)"
|
||||
OUT="${REPO}/core/dr-segment/models"
|
||||
|
||||
MODEL="${1:-yolo26n-seg}"
|
||||
IMGSZ="${2:-640}"
|
||||
WORK="$(mktemp -d)"
|
||||
trap 'rm -rf "${WORK}"' EXIT
|
||||
|
||||
echo "==> exporting ${MODEL} in ${WORK}"
|
||||
echo "==> exporting ${MODEL} at imgsz=${IMGSZ} in ${WORK}"
|
||||
cd "${WORK}"
|
||||
uv venv --python 3.12 venv
|
||||
VIRTUAL_ENV="${WORK}/venv" uv pip install ultralytics onnx onnxslim
|
||||
|
||||
VIRTUAL_ENV="${WORK}/venv" "${WORK}/venv/bin/python" - "${MODEL}" <<'PY'
|
||||
VIRTUAL_ENV="${WORK}/venv" "${WORK}/venv/bin/python" - "${MODEL}" "${IMGSZ}" <<'PY'
|
||||
import sys, json
|
||||
from ultralytics import YOLO
|
||||
|
||||
name = sys.argv[1]
|
||||
imgsz = int(sys.argv[2])
|
||||
m = YOLO(f"{name}.pt")
|
||||
path = m.export(format="onnx", opset=17, simplify=True, imgsz=640, dynamic=False)
|
||||
path = m.export(format="onnx", opset=17, simplify=True, imgsz=imgsz, dynamic=False)
|
||||
print("ONNX:", path)
|
||||
|
||||
# The class names travel with the model rather than being retyped into Rust —
|
||||
|
||||
Reference in New Issue
Block a user