RuntimeError: unexpected EOF, expected 73963 more bytes. The file might be corrupted.
Problem Description:
When the project executes Python script, when downloading the pre training model weight of pytorch, if the weight is not downloaded due to network instability and other reasons, an error will be reported runtimeerror: unexpected EOF, expected xxxxx more bytes The file might be corrupted.
Cause analysis:
This error indicates that the downloaded weight file may be damaged. You need to delete the damaged weight file and execute the code to download again.
Solution:
To find the location where the downloaded weight file is saved, this paper analyzes three situations:
1. Windows System & Anaconda Environment
The path of download is D:\Anaconda3\anaconda\envs\yypy36\Lib\site-packages\facexlib\weightsdetection_Resnet50_Final.pt
, so you need go to this folder and delete the weight file as the screenshot below:
2. Windows system & Python environment:
The code automatically downloads the model weights file and saves it to the C:\Users\username/.cache\torch\checkpoints
folder. Note that .cache may be a hidden file, you need to view the hidden file to see it, just delete the weight file.
3. Linux systems:
Linux system weights files are usually saved under: \home\username\.cache\torch
. Note that .cache is a hidden folder and will only be shown if you press ctrl+Alt+H in winSCP; or, in the home directory, use ls -a to show it. root mode, the default path for downloaded weight files is under: /root/.cache/torch/checkpoints
. Just delete the weight file.
In the above three cases, after deleting the weight file, execute the code again to download again.
Additional:
If the execution program downloads the code too slowly or the network stability is not good, we can directly download it manually from the website where the weight file is located and put it in the specified location. The Linux system can adopt WGet method.
wget -P Local path where the weights are saved Address of the weights
If the download is interrupted, WGet supports continuous transmission at breakpoints. Add a parameter - C
:
wget -P Local path where weights are saved -c Address of weights
eg:
wget -P /home/20220222Proj/pretrained_models -c https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth
Read More:
- [Solved] Python Read bam File Error: &&OSError: no BGZF EOF marker; file may be truncated
- Syntaxerror: unexpected EOF while parsing solution and ideas
- [Solved] RuntimeError: DefaultCPUAllocator: not enough memory: you tried to allocate 1105920 bytes.
- Python PIP TypeError: expected str, bytes or os.PathLike object, not int
- How to Solve RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu
- [Solved] RuntimeError: expected scalar type Long but found Float
- [Solved] RuntimeError: gather(): Expected dtype int64 for index
- [Solved] Backtrader_plotting Error: RuntimeError: Unexpected data type
- [Solved] RuntimeError: scatter(): Expected dtype int64 for index
- [Solved] Pytorch Error: RuntimeError: expected scalar type Double but found Float
- Typeerror in Python regular expression: expected string or bytes like object
- Python RuntimeError: Expected 4-dimensional input for 4-dimensional weight [32, 1, 5, 5]
- Pytorch Error: runtimeerror: expected scalar type double but found float
- [Solved] Python Error: TypeError: write() argument must be str, not bytes
- [Solved] pycocotools Install Error: ERROR: Error expected str, bytes or os.PathLike object, not NoneType while executing
- [Solved] wsgiref make_server Error: AssertionError: write() argument must be a bytes instance
- [Solved] python-sutime Error: the JSON object must be str, bytes or bytearray, not ‘java.lang.String‘
- Pytorch Error: RuntimeError: value cannot be converted to type float without overflow: (0.00655336,-0.00
- [Solved] Arcpy: RuntimeError: ERROR 999998: Unexpected Error.
- Autograd error in Python: runtimeerror: grad can be implicitly created only for scalar outputs