Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Uploading Pretrained Checkpoints to Hugging Face
|
| 2 |
+
|
| 3 |
+
This guide explains how to upload model checkpoints to a shared Hugging Face repository using `huggingface_hub`.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 1. Prerequisites
|
| 8 |
+
|
| 9 |
+
Activate your conda environment, then install the Hugging Face Hub client **inside it**:
|
| 10 |
+
|
| 11 |
+
```bash
|
| 12 |
+
conda activate <your-env>
|
| 13 |
+
pip install huggingface_hub
|
| 14 |
+
```
|
| 15 |
+
|
| 16 |
+
Verify it is installed correctly:
|
| 17 |
+
|
| 18 |
+
```bash
|
| 19 |
+
python -c "import huggingface_hub; print(huggingface_hub.__version__)"
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
> **Note on CLI command name:** In `huggingface_hub` v1.0+, the CLI was renamed from `huggingface-cli` to **`hf`**. If you are on v1.x (check with the command above), use `hf` everywhere in this guide. If the command is still not found despite the package being installed, use the module fallback:
|
| 23 |
+
>
|
| 24 |
+
> ```bash
|
| 25 |
+
> python -m huggingface_hub.cli.hf --version
|
| 26 |
+
> ```
|
| 27 |
+
>
|
| 28 |
+
> Use `python -m huggingface_hub.cli.hf` as a drop-in replacement for `hf` anywhere below.
|
| 29 |
+
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
## 2. Create a Hugging Face Account
|
| 33 |
+
|
| 34 |
+
Go to [huggingface.co](https://huggingface.co) and create a personal account if you do not have one. Ask the organisation owner to add you as a member of the shared organisation so you have write access to the repository.
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
## 3. Log in
|
| 39 |
+
|
| 40 |
+
```bash
|
| 41 |
+
hf auth login
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
You will be prompted for an access token. Generate one at:
|
| 45 |
+
**huggingface.co → Settings → Access Tokens → New token** (role: **Write**)
|
| 46 |
+
|
| 47 |
+
Paste the token when prompted. Your credentials are stored locally and persist across sessions.
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## 4. Create a Repository in the Organisation
|
| 52 |
+
|
| 53 |
+
Before uploading, you need a repository to upload to. Create one under the organisation with:
|
| 54 |
+
|
| 55 |
+
```bash
|
| 56 |
+
hf repos create AICM-HD/<repo-name> --repo-type model
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
Add `--private` if the repository should not be publicly visible:
|
| 60 |
+
|
| 61 |
+
```bash
|
| 62 |
+
hf repos create AICM-HD/<repo-name> --repo-type model --private
|
| 63 |
+
```
|
| 64 |
+
---
|
| 65 |
+
|
| 66 |
+
## 6. Checkpoint Naming Convention
|
| 67 |
+
|
| 68 |
+
Before uploading, rename checkpoints to make them unambiguous. A clear convention is:
|
| 69 |
+
|
| 70 |
+
```
|
| 71 |
+
{model}_{dataset}.pth
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
For example: `vqgan_chestct.pth`, `ldm_chestct.pth`, etc.
|
| 75 |
+
|
| 76 |
+
---
|
| 77 |
+
|
| 78 |
+
## 7. Upload Checkpoints
|
| 79 |
+
|
| 80 |
+
Replace `<org>/<repo>` with the actual organisation/repository name on Hugging Face.
|
| 81 |
+
|
| 82 |
+
**Upload a single file:**
|
| 83 |
+
|
| 84 |
+
```bash
|
| 85 |
+
hf upload <org>/<repo> \
|
| 86 |
+
/path/to/local/checkpoint.pth \
|
| 87 |
+
checkpoint.pth \
|
| 88 |
+
--repo-type model
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
The third argument is the destination filename inside the repository.
|
| 92 |
+
|
| 93 |
+
**Upload all checkpoints at once from a folder:**
|
| 94 |
+
|
| 95 |
+
```bash
|
| 96 |
+
hf upload <org>/<repo> \
|
| 97 |
+
/path/to/checkpoints/ \
|
| 98 |
+
. \
|
| 99 |
+
--repo-type model
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
This uploads the entire folder contents to the root of the repository.
|
| 103 |
+
|
| 104 |
+
---
|
| 105 |
+
|
| 106 |
+
## 8. Verify the Upload
|
| 107 |
+
|
| 108 |
+
Open the repository in a browser:
|
| 109 |
+
|
| 110 |
+
```
|
| 111 |
+
https://huggingface.co/<org>/<repo>
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
You should see the uploaded files listed under **Files and versions**. Click any file to confirm its size matches the local checkpoint.
|
| 115 |
+
|
| 116 |
+
You can also verify from the terminal:
|
| 117 |
+
|
| 118 |
+
```bash
|
| 119 |
+
hf repo info <org>/<repo> --repo-type model
|
| 120 |
+
```
|
| 121 |
+
|
| 122 |
+
---
|
| 123 |
+
|
| 124 |
+
## 9. Downloading Checkpoints
|
| 125 |
+
|
| 126 |
+
Anyone with access to the repository can download checkpoints with:
|
| 127 |
+
|
| 128 |
+
```bash
|
| 129 |
+
pip install huggingface_hub
|
| 130 |
+
|
| 131 |
+
hf download <org>/<repo> checkpoint.pth --local-dir checkpoints/
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
Or download everything at once:
|
| 135 |
+
|
| 136 |
+
```bash
|
| 137 |
+
hf download <org>/<repo> --local-dir checkpoints/
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
If the repository is private, members must log in first (`hf auth login`) with their own access token.
|
| 141 |
+
|
| 142 |
+
---
|