From d550c12a3eda0aeceacc8013f9f77808d9f524be Mon Sep 17 00:00:00 2001 From: Nikita Skakun Date: Thu, 30 Mar 2023 12:52:16 -0700 Subject: [PATCH] Fixed the bug with additional bytes. The issue seems to be with huggingface not reporting the entire size of the model. Added an error message with instructions if the checksums don't match. --- download-model.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/download-model.py b/download-model.py index 0b3f16d7..52cdae81 100644 --- a/download-model.py +++ b/download-model.py @@ -35,7 +35,7 @@ def get_file(url, output_folder): # Check if the file has already been downloaded completely r = requests.head(url) total_size = int(r.headers.get('content-length', 0)) - if output_path.stat().st_size == total_size: + if output_path.stat().st_size >= total_size: return # Otherwise, resume the download from where it left off headers = {'Range': f'bytes={output_path.stat().st_size}-'} @@ -215,7 +215,6 @@ if __name__ == '__main__': print(f"Downloading the model to {output_folder}") download_files(links, output_folder, args.threads) - print('\n') # Validate the checksums validated = True for i in range(len(sha256)): @@ -227,4 +226,6 @@ if __name__ == '__main__': validated = False if validated: - print('[+] Validated checksums of all model files!') \ No newline at end of file + print('[+] Validated checksums of all model files!') + else: + print('[-] Rerun the download-model.py with --clean flag') \ No newline at end of file