A Python script for efficiently downloading and reconstructing large Hugging Face model files by splitting them into manageable chunks.
- π Downloads large model files from Hugging Face in multiple parts simultaneously
- π Automatically extracts download links from the model page
- π§ Allows customization of the number of parts for splitting files
- 𧩠Combines downloaded parts back into the original file
- π Displays download progress for each file
- Python 3.6+
requests
librarytqdm
library
- Clone this repository:
git clone https://github.com/sioaeko/huggingface-split-downloader.git
cd huggingface-split-downloader
- Install the required dependencies:
pip install requests tqdm
Run the script with the following command:
python huggingface_split_downloader.py <model_url> <output_dir> --parts <number_of_parts>
<model_url>
: The URL of the Hugging Face model page<output_dir>
: The directory where you want to save the downloaded files--parts
: (Optional) The number of parts to split each file into (default is 5)
python huggingface_split_downloader.py https://huggingface.co/gpt2 ./downloaded_model --parts 10
This command will download the GPT-2 model files, splitting each file into 10 parts, and save them in the ./downloaded_model
directory.
- π Access the provided Hugging Face model page and extract download links
- For each file:
- π Determine the file size
- βοΈ Split the download into the specified number of parts
- π₯ Download each part concurrently
- π Show a progress bar for the download
- 𧩠Combine parts back into the original file
- ποΈ Delete partial files after successful combination
- πΎ Ensure you have sufficient storage space for the model files
- π Download speed may vary depending on your internet connection
- π The script may need adjustments if the structure of the Hugging Face website changes
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This tool is for educational and research purposes. Always ensure you have the right to download and use the models as per Hugging Face's terms of service.