[Solved] torchvision.models.resnet18() Error: PytorchStreamReader failed reading zip archive: failed finding…

When I was downloading the resnet18 network using torchvision.models.resnet18(), I manually terminated it once and when I ran it again, I got the error PytorchStreamReader failed reading zip archive: failed finding central directory

This is because after manually terminating the program, the file was halfway down, but when I rerun it, the program thought it was done and started unpacking, which resulted in an error. Here is the file I downloaded halfway:

The procedure to detect if the file already exists is in the torch.hub file at line 585, follow the error message to find the torch.hub file

Type a breakpoint here, debug it, then see what the value of cached_file is here, follow the path of cached_file to find the file that is halfway down, delete it and you’re done.

When I run it, the path of this file looks like this

Read More: