Skip to content

Instantly share code, notes, and snippets.

@bodaay
Created June 25, 2023 16:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bodaay/137b66f6e28e580c7d3fa36177bd2712 to your computer and use it in GitHub Desktop.
Save bodaay/137b66f6e28e580c7d3fa36177bd2712 to your computer and use it in GitHub Desktop.
HuggingFace Model Downloader
#!/bin/bash
args=${@:1} # Capture user-provided arguments
os=$(uname -s | tr '[:upper:]' '[:lower:]')
arch=$(uname -m | tr '[:upper:]' '[:lower:]')
if [ "$arch" = "x86_64" ]; then
arch="amd64"
fi
repo="bodaay/HuggingFaceModelDownloader"
latest_tag=$(curl --silent "https://api.github.com/repos/$repo/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
url="https://github.com/${repo}/releases/download/${latest_tag}/hfdownloader_${os}_${arch}_${latest_tag}"
# echo $url
file_path="hfdownloader"
if [[ -f "$file_path" ]]; then
echo "File already exists. Skipping download."
else
curl -o $file_path -L $url \
--fail --silent --show-error --output /dev/null \
&& echo "Download successful" \
|| (echo "Download failed"; rm -f $file_path)
chmod +x $file_path
fi
if [[ -z "$args" ]]; then
args="-h" # Set default arguments if no user-provided arguments
fi
./$file_path $args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment