Download restore.sh from zwc2003/tmp-2: direct link, hf CLI and curl.
- Browser
- Download file 970 Bytes
-
https://huggingface.co/zwc2003/tmp-2/resolve/main/restore.sh
- Command line
-
hf download hf://zwc2003/tmp-2/restore.sh
-
curl -L -o restore.sh https://huggingface.co/zwc2003/tmp-2/resolve/main/restore.sh
970 Bytes
| # Extract every archive in MANIFEST.json (shards and linked archives with an extract_to) into <ROOT>, then verify. | |
| # bash restore.sh <ROOT> [parallel jobs, default 8] | |
| # Download the repo into <ROOT> itself (hf download ... --local-dir <ROOT>) so weight folders are already in place. | |
| set -euo pipefail | |
| repo=$(cd "$(dirname "$0")" && pwd) | |
| root=${1:?usage: restore.sh <ROOT> [jobs]} | |
| mkdir -p "$root" | |
| root=$(cd "$root" && pwd) | |
| jobs=${2:-8} | |
| python3 - "$repo" <<'EOF' > "$repo/.restore_list" | |
| import json, sys | |
| m = json.load(open(sys.argv[1] + '/MANIFEST.json')) | |
| for item in m['shards'] + [l for l in m['links'] if 'extract_to' in l]: | |
| print(item['path'] + '\t' + item['extract_to']) | |
| EOF | |
| while IFS=$'\t' read -r path dest; do | |
| mkdir -p "$root/$dest" | |
| printf '%s\0%s\0' "$repo/$path" "$root/$dest" | |
| done < "$repo/.restore_list" | xargs -0 -n 2 -P "$jobs" sh -c 'tar -xf "$0" -C "$1" && echo "extracted $0"' | |
| python3 "$repo/verify_restore.py" "$repo" "$root" | |