I want to play with the dusty nv classification again, However, there is an error. It was fine couple years ago. Is it the pytorch version problem? Mine is 1.6. Jetpack is 4.6. May I know how to solve it?
Note: I have tried to git clone the newest dustynv Inference in another board, same error…
Thx
nvidia@nvidia-desktop:~/jetson-inference_2021/python/training/classification$ python3 train.py --model-dir=models/cat_dog data/cat_dog
Use GPU: 0 for training
=> dataset classes: 2 ['cat', 'dog']
=> using pre-trained model 'resnet18'
Traceback (most recent call last):
File "train.py", line 506, in <module>
main()
File "train.py", line 135, in main
main_worker(args.gpu, ngpus_per_node, args)
File "train.py", line 199, in main_worker
model = models.__dict__[args.arch](pretrained=True)
File "/home/nvidia/.local/lib/python3.6/site-packages/torchvision/models/resnet.py", line 277, in resnet18
**kwargs)
File "/home/nvidia/.local/lib/python3.6/site-packages/torchvision/models/resnet.py", line 263, in _resnet
progress=progress)
File "/home/nvidia/.local/lib/python3.6/site-packages/torch/hub.py", line 490, in load_state_dict_from_url
raise RuntimeError('Only one file(not dir) is allowed in the zipfile')
RuntimeError: Only one file(not dir) is allowed in the zipfile
Hi @AK51, I haven’t seen this error before, and wonder if somehow your torch model cache has a corrupt download in it. Can you try clearing it like this?
Still not working… I have tried two boards with working SD image (I burned them long time ago and object detection works. Never tried classification in them) Maybe the torch resnet18 has problem? Thx
“https://download.pytorch.org/models/resnet18-f37072fd.pth”?
I saw this link but no solution…, Unable to load model state_dict using torch.utils.model_zoo.load_url() - PyTorch Forums
“Maybe that’s what I trained in Google Collab and I just noticed collab uses torch version1.6 where _use_new_zipfile_serialization is True by default”
Maybe “_use_new_zipfile_serialization” is not explicitly set in nano board? Thx
nvidia@nvidia-desktop:~$ cd ~/.cache/torch
nvidia@nvidia-desktop:~/.cache/torch$ ls
hub
nvidia@nvidia-desktop:~/.cache/torch$ cd hub
nvidia@nvidia-desktop:~/.cache/torch/hub$ ls
checkpoints
nvidia@nvidia-desktop:~/.cache/torch/hub$ cd checkpoints/
nvidia@nvidia-desktop:~/.cache/torch/hub/checkpoints$ ls
alexnet-owt-4df8aa71.pth resnet18-5c106cde.pth resnet18-f37072fd.pth
nvidia@nvidia-desktop:~/.cache/torch/hub/checkpoints$ rm resnet18-5c106cde.pth
nvidia@nvidia-desktop:~/.cache/torch/hub/checkpoints$ rm resnet18-f37072fd.pth
nvidia@nvidia-desktop:~/.cache/torch/hub/checkpoints$ rm alexnet-owt-4df8aa71.pth
rm: remove write-protected regular file 'alexnet-owt-4df8aa71.pth'? y
nvidia@nvidia-desktop:~/.cache/torch/hub/checkpoints$ ls
etson-inference_2021/python/training/classification$ python3 train.py --model-dir=models/cat_dog data/cat_dog
Use GPU: 0 for training
=> dataset classes: 2 ['cat', 'dog']
=> using pre-trained model 'resnet18'
Downloading: "https://download.pytorch.org/models/resnet18-f37072fd.pth" to /home/nvidia/.cache/torch/hub/checkpoints/resnet18-f37072fd.pth
100%|██████████████████████████████████████| 44.7M/44.7M [00:03<00:00, 11.9MB/s]
Traceback (most recent call last):
File "train.py", line 506, in <module>
main()
File "train.py", line 135, in main
main_worker(args.gpu, ngpus_per_node, args)
File "train.py", line 199, in main_worker
model = models.__dict__[args.arch](pretrained=True)
File "/home/nvidia/.local/lib/python3.6/site-packages/torchvision/models/resnet.py", line 277, in resnet18
**kwargs)
File "/home/nvidia/.local/lib/python3.6/site-packages/torchvision/models/resnet.py", line 263, in _resnet
progress=progress)
File "/home/nvidia/.local/lib/python3.6/site-packages/torch/hub.py", line 490, in load_state_dict_from_url
raise RuntimeError('Only one file(not dir) is allowed in the zipfile')
RuntimeError: Only one file(not dir) is allowed in the zipfile
File "imagenet.py", line 68, in <module>
class_id, confidence = net.Classify(img)
Exception: jetson.inference -- imageNet.Classify() encountered an error classifying the image
Thanks for reporting this @AK51 - I cleared my torchhub model cache and retested this on JetPack 4.6.1, and it was able to download and load the resnet18.pth without issue. What version of PyTorch and torchvision are you using?