Search before asking
#1035 concerns TFLite support in 1.6.5, not this PATH failure. Searches in PINTO0309/onnx2tf also found no matching issue.
Bug
model.export(format="tflite") fails when RF-DETR runs through <venv>/bin/python without activating the virtual environment.
onnx2tf 2.4.3 calls the bare onnxsim console script. Invoking Python by absolute path does not add <venv>/bin to PATH, so the onnxsim installed by rfdetr[tflite] cannot be found.
onnx2tf contains this comment above the first call:
To fully optimize the model, run onnxsim three times in a row.
Due to unstable script execution of onnxsim in v0.4.8,
I have no choice but to use subprocesses that we do not want to use.
A clean pip install "rfdetr[tflite]==1.9.3" with stock RFDETRSmall() produced:
FileNotFoundError: [Errno 2] No such file or directory: 'onnxsim'
WARNING: Failed to optimize the onnx file.
RuntimeError: onnx2tf conversion failed: Output tensors of a Functional model must be the output of a TensorFlow Layer (thus holding past layer metadata).
No .tflite file is written. The final RuntimeError above was observed on stock RFDETRSmall(); it is not claimed for other variants.
Adding <venv>/bin to PATH makes the same export finish. onnxsim still returns exit status 1 after rewriting the graph.
Failed to optimize the onnx file appears in both runs. FileNotFoundError: ... 'onnxsim' identifies this failure.
Linux, Windows, and onnx2tf versions after 2.4.3 were not runtime-tested. Source inspection found the same bare onnxsim invocation in onnx2tf 2.6.8. The reason onnxsim returns exit status 1 when found is unknown.
Environment
- macOS 26.5.2 (25F84) arm64, Apple M4, Python 3.12.12, no CUDA
- RF-DETR 1.9.3 from PyPI (
sha256:3f19602ee7487dd80d8d2774e8dcd9380aba1eae9f86a8ba1c5d558b143236ef)
- onnx2tf 2.4.3, onnxsim 0.7.3, TensorFlow 2.19.1, torch 2.13.0, onnx 1.20.1
Minimal Reproducible Example
REPRO_ROOT="$(mktemp -d /tmp/rfdetr-onnxsim-clean.XXXXXX)"
REPRO_VENV="$REPRO_ROOT/venv"
python3.12 -m venv "$REPRO_VENV"
"$REPRO_VENV/bin/python" -m pip install --upgrade pip
"$REPRO_VENV/bin/python" -m pip install --no-cache-dir "rfdetr[tflite]==1.9.3"
cat > "$REPRO_ROOT/repro.py" <<'PY'
import os
import shutil
import sys
from rfdetr import RFDETRSmall
print("python:", sys.executable)
print("PATH:", os.environ["PATH"])
print("onnxsim:", shutil.which("onnxsim"))
RFDETRSmall().export(
format="tflite",
output_dir=sys.argv[1],
shape=(512, 512),
batch_size=1,
)
PY
env -u PYTHONPATH -u VIRTUAL_ENV \
PATH="/usr/bin:/bin:/usr/sbin:/sbin" \
"$REPRO_VENV/bin/python" "$REPRO_ROOT/repro.py" "$REPRO_ROOT/no-path"
The same command succeeds when PATH starts with "$REPRO_VENV/bin".
Are you willing to submit a PR?
Search before asking
#1035 concerns TFLite support in 1.6.5, not this PATH failure. Searches in PINTO0309/onnx2tf also found no matching issue.
Bug
model.export(format="tflite")fails when RF-DETR runs through<venv>/bin/pythonwithout activating the virtual environment.onnx2tf2.4.3 calls the bareonnxsimconsole script. Invoking Python by absolute path does not add<venv>/bintoPATH, so theonnxsiminstalled byrfdetr[tflite]cannot be found.onnx2tf contains this comment above the first call:
A clean
pip install "rfdetr[tflite]==1.9.3"with stockRFDETRSmall()produced:No
.tflitefile is written. The finalRuntimeErrorabove was observed on stockRFDETRSmall(); it is not claimed for other variants.Adding
<venv>/bintoPATHmakes the same export finish.onnxsimstill returns exit status 1 after rewriting the graph.Failed to optimize the onnx fileappears in both runs.FileNotFoundError: ... 'onnxsim'identifies this failure.Linux, Windows, and onnx2tf versions after 2.4.3 were not runtime-tested. Source inspection found the same bare
onnxsiminvocation in onnx2tf 2.6.8. The reasononnxsimreturns exit status 1 when found is unknown.Environment
sha256:3f19602ee7487dd80d8d2774e8dcd9380aba1eae9f86a8ba1c5d558b143236ef)Minimal Reproducible Example
The same command succeeds when
PATHstarts with"$REPRO_VENV/bin".Are you willing to submit a PR?