facebookresearch / facebookresearch/segment-anything

Onnx opset missmatch (opset 17 only supported in pytorch>=2)

Open
#18 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
54.9k
Forks
6.4k
PR merge metrics
No merged PRs in 30d

Description

The README says the code requires pytorch>=1.7 but the `onnx_model_example.ipynb` expected `opset=17`. Is far as I can tell `opset 17` is only supported in `pytorch>=2`.

1. Should the readme be updated? Or
2. Can I just set `opset_version=16` in the [notebook](https://github.com/facebookresearch/segment-anything/blob/main/notebooks/onnx_model_example.ipynb)?

```python
with open(onnx_model_path, "wb") as f:
torch.onnx.export(
onnx_model,
tuple(dummy_inputs.values()),
f,
export_params=True,
verbose=False,
opset_version=17, # <---- :-(
do_constant_folding=True,
input_names=list(dummy_inputs.keys()),
output_names=output_names,
dynamic_axes=dynamic_axes,
)
```

Happy to make the changes and make a PR with any desired solution.

Contributor guide

Open the contributing guide

Research direction

Start by comparing the PyTorch requirement in README with the export cell in notebooks/onnx_model_example.ipynb, especially its opset_version=17 setting. Verify which opset works with the stated supported versions, then update the README or notebook so the documented requirement and example agree and the notebook export completes.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, pytorch
Domain
documentation, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.