Better way to download particular versions and track progress

#4
by hrishbhdalal - opened

Hi,
I was using git lfs, but is there some other way to download particular repos? I would appreciate the help!

That's what I'm doing as well, git clone --branch, but I think textgen-web-ui's downloader has a way to do it too.

huggingface-cli is convenient.

i am using this:

import os
import shutil
from huggingface_hub import snapshot_download

Define the model, branches, and storage directory

model = "turboderp/Mixtral-8x22B-Instruct-v0.1-exl2"
branches = [
# "2.7bpw",
"3.0bpw",
"3.5bpw",
"4.0bpw",
"4.5bpw"]
storage_dir = "local_model_loc"

Loop through each branch and download it to a subdirectory of the storage directory

for branch in branches:
print(f'downloading branch: {branch}')
# Define the name of the subdirectory where the branch will be downloaded
subdir = f"{model}_{branch}"

# Define the full path to the subdirectory
full_path = os.path.join(storage_dir, subdir)

# Ensure the subdirectory is empty or clear it if not
if os.path.exists(full_path) and os.listdir(full_path):
    shutil.rmtree(full_path)  # Remove the directory and all its contents

# Create the subdirectory if it doesn't exist
os.makedirs(full_path, exist_ok=True)

# Download the specific branch
snapshot_download(repo_id=model, revision=branch, local_dir=full_path, local_dir_use_symlinks=False, resume_download=True, cache_dir=full_path)

works quite well. made it recently.

Sign up or log in to comment