IsADirectoryError while running onnx_export.py

Hello!

I follow this tutorial jetson-inference/pytorch-ssd.md at master · dusty-nv/jetson-inference · GitHub and when I run
python3 onnx_export.py --model-dir=models/mymodel
, I get the following error:

Namespace(batch_size=1, height=300, input='', labels='labels.txt', model_dir='models/weeds', net='ssd-mobilenet', output='', width=300)
running on device cuda:0
found best checkpoint with loss 10000.000000 ()
creating network:  ssd-mobilenet
num classes:       3
loading checkpoint:  models/weeds/
Traceback (most recent call last):
  File "onnx_export.py", line 86, in <module>
    net.load(args.input)
  File "/home/maria/jetson-inference/python/training/detection/ssd/vision/ssd/ssd.py", line 135, in load
    self.load_state_dict(torch.load(model, map_location=lambda storage, loc: storage))
  File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 594, in load
    with _open_file_like(f, 'rb') as opened_file:
  File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 230, in _open_file_like
    return _open_file(name_or_buffer, mode)
  File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 211, in __init__
    super(_open_file, self).__init__(open(name, mode))
IsADirectoryError: [Errno 21] Is a directory: 'models/mymodel/'

How can I solve this problem?

Thank you!

Hi @akimenkova.ma, can you check the contents of your models/weeds/ directory with ls models/weeds/ ?

Does it have any checkpoint files in it?

Hi!

Yes, there are .pth files in it.

Hmm, ok - not sure why the error then. What I recommend is manually specifying these command line arguments instead:

  • --input path to PTH checkpoint with the lowest loss
  • --output=models/weeds/ssd-mobilenet.onnx
  • --labels=models/weeds/labels.txt