KaiyangZhou / deep-person-reid

Torchreid: Deep learning person re-identification in PyTorch.
https://kaiyangzhou.github.io/deep-person-reid/
MIT License
4.33k stars 1.15k forks source link

Missing packages when trying to export models to ONNX from Docker container #559

Open xperroni opened 1 year ago

xperroni commented 1 year ago

Running the tools/export.py script from the Docker container fails due to missing Python packages.

For example, running:

python tools/export.py --weights osnet_x0_25_imagenet.pth --include onnx --imgsz 256 128

Fails with error:

Traceback (most recent call last):
  File "tools/export.py", line 7, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'

After installing pandas the same call fails with error:

export failure: No module named 'onnx'
Traceback (most recent call last):
  File "tools/export.py", line 200, in <module>
    f = export_onnx(extractor.model.eval(), im, args.weights, 12, train=False, dynamic=args.dynamic, simplify=True)  # opset 12
  File "tools/export.py", line 98, in export_onnx
    return f
UnboundLocalError: local variable 'f' referenced before assignment

After going through a few turns of this, I eventually found the complete list of missing packages. They can be installed with:

pip install pandas onnx==1.8.0 onnxsim onnxruntime
bmmtstb commented 1 year ago

I know that I had the same issues while using pip install torchreid without docker. But I solved it similarly.

The following code in the requirements.txt is commented out:

https://github.com/KaiyangZhou/deep-person-reid/blob/566a56a2cb255f59ba75aa817032621784df546a/requirements.txt#L18-L24

Is that the issue?