semantic-segmentation: tarfile.EmptyHeaderError: empty header
Hi
I am having a problem when I try to run the demo.py. When I run the following command:
python3 demo.py --demo-image test.png --snapshot pretrained_models/cityscapes_best.pth
I get the error:
Using regular batch norm
Net built.
Traceback (most recent call last):
File "/usr/lib/python3.6/tarfile.py", line 2297, in next
tarinfo = self.tarinfo.fromtarfile(self)
File "/usr/lib/python3.6/tarfile.py", line 1093, in fromtarfile
obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
File "/usr/lib/python3.6/tarfile.py", line 1029, in frombuf
raise EmptyHeaderError("empty header")
tarfile.EmptyHeaderError: empty header
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 595, in _load
return legacy_load(f)
File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 506, in legacy_load
with closing(tarfile.open(fileobj=f, mode='r:', format=tarfile.PAX_FORMAT)) as tar, \
File "/usr/lib/python3.6/tarfile.py", line 1589, in open
return func(name, filemode, fileobj, **kwargs)
File "/usr/lib/python3.6/tarfile.py", line 1619, in taropen
return cls(name, mode, fileobj, **kwargs)
File "/usr/lib/python3.6/tarfile.py", line 1482, in __init__
self.firstmember = self.next()
File "/usr/lib/python3.6/tarfile.py", line 2312, in next
raise ReadError("empty file")
tarfile.ReadError: empty file
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "demo.py", line 32, in <module>
net, _ = restore_snapshot(net, optimizer=None, snapshot=args.snapshot, restore_optimizer_bool=False)
File "/home/sieuwe/Downloads/semantic-segmentation-master/optimizer.py", line 69, in restore_snapshot
checkpoint = torch.load(snapshot, map_location=torch.device('cpu'))
File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 426, in load
return _load(f, map_location, pickle_module, **pickle_load_args)
File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 597, in _load
if _is_zipfile(f):
File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 75, in _is_zipfile
if ord(magic_byte) != ord(read_byte):
TypeError: ord() expected a character, but string of length 0 found
I believe the error accours when it is loading the pretrained_models/wider_resnet38.pth.tar. But I dont know what I have done wrong.
The steps I followed where:
- clone repo
- Install all dependencies
- download cityscapes_best.pth and wider_resnet38.pth.tar
- make a folder called pretrained_models in repo root and add the two mentioned files.
- type above mentioned command to run demo.
My system Ubuntu 18.4 LTS python 3.6 Cuda 10.2 Driver 440.33.01 card GTX1080
PS: I am also wondering if there is a python video implementation for this network which can take a normal video as input? Because the Demo.py is only for images right? Or can I make a loop which loops over a video and per frame makes a prediction using the net(img) function. If that is possible what will the FPS be for such an implementation on a GTX1080?
Thanks
Sieuwe
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (1 by maintainers)
@bryanyzhu
If you are interested to see what I made using your model and how it performs in my application you can watch this youtube video I made about it.
https://youtu.be/fH-g9boR2qA
It works already really well and thanks again for sharing the model.
I also tested your model on the Jetson with the realtime implementation I made. It does not perform well sadly. Around 1 fps and sometimes even lower. This is when I just make a while loop and every loop call the predict function. No optimization like batch processing. If you find it is useful I can do some more testing on the Jetson for you.
Thanks
Sieuwe
@bryanyzhu
Yes that was the problem works perfectly now. Would not say that it is twice as fast but definitely faster!
Also made it that the model only analysis the video every 10th frame. This speeds up the program a lot so that it is now very usable for my self driving vehicle.
Thanks for your help again
Greetings
Sieuwe
Thank you very much.
1
np.array(colorized.convert('RGB'))
works great!2 Great ill try out connected components for smoothing once I am at that stage.
Thanks for all your advice
Really appreciate NVIDIA making this open source so that students like me can use these very advanced techniques for free.
Greetings
Sieuwe