RuntimeError: unexpected EOF, expected 73963 more bytes. The file might be corrupted. 解决方案
Problem Description:
When the project project executes the python script, when downloading the pre-trained model weights of pytorch, if the weights are not downloaded due to network instability or 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 then execute the code to download it again.
solution:
To find the location where the downloaded weight file is saved, this article analyzes three situations:
-
Windows system Anaconda environment:
As the red box in the picture in the problem description section is visible, the download location is.D:\Anaconda3\anaconda\envs\yypy36\Lib\site-packages\facexlib\weightsdetection_Resnet50_Final.pth
Therefore, directly enter the corresponding folder and delete the weight file. As shown below:
-
Ordinary Python environment for Windows systems:
The code automatically downloads the model weight file and saves it toC:\Users\用户名/.cache\torch\checkpoints
the folder. Note that .cache may be a hidden file. You need to view the hidden file to see it. Just delete the weight file. -
Linux system:
Linux system weight files are usually saved\home\用户名\.cache\torch
under :. It should be noted that .cache is a hidden folder, which can only be displayed by pressing ctrl+Alt+H in winSCP; or, in the home directory, use ls -a to display it.root
In mode, the default saving path of the downloaded weight file is: /root/.cache/torch/checkpoints. Just delete the weight file.
In the above three cases, after deleting the weight file, re-execute the code to download it again.
Replenish
If it is too slow to execute the program to download the code or the network stability is not good, we can directly go to the website where the weight file is located to manually download it and put it into the specified location. For Linux systems, the wget method can be used.
wget -P 权重文件保存的本地路径 权重文件地址
If the download is interrupted, wget supports breakpoint resuming, -c
just add a parameter:
wget -P 权重文件保存的本地路径 -c 权重文件地址
eg:
wget -P /home/20220222Proj/pretrained_models -c https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth
References to this article:
1、unexpected EOF, expected 455433 more bytes. The file might be corrupted.解决方案
2、RuntimeError: unexpected EOF, expected 23361873 more bytes. The file might be
3、unexpected EOF, expected 65478 more bytes. The file might be corrupted.问题解决方案
4、RuntimeError: unexpected EOF, expected 309663195 more bytes. The file might be corrupted.暴力解决