Datasets:

License:
File size: 3,420 Bytes
0914308
 
 
 
 
1ee9349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a5b0a3a
1ee9349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
de02b5d
1ee9349
 
 
 
de02b5d
1ee9349
 
 
 
 
 
 
 
 
 
de02b5d
1ee9349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
de02b5d
1ee9349
 
 
 
 
 
 
 
 
 
 
de02b5d
1ee9349
 
 
 
 
de02b5d
1ee9349
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
---
license: other
---


# Uploading Pretrained Checkpoints to Hugging Face

This guide explains how to upload model checkpoints to a shared Hugging Face repository using `huggingface_hub`.

---

## 1. Prerequisites

Activate your conda environment, then install the Hugging Face Hub client **inside it**:

```bash
conda activate <your-env>
pip install huggingface_hub
```

Verify it is installed correctly:

```bash
python -c "import huggingface_hub; print(huggingface_hub.__version__)"
```

> **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:
>
> ```bash
> python -m huggingface_hub.cli.hf --version
> ```
>
> Use `python -m huggingface_hub.cli.hf` as a drop-in replacement for `hf` anywhere below.

---

## 2. Create a Hugging Face Account

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.

---

## 3. Log in

```bash
hf auth login
```

You will be prompted for an access token. Generate one at:
**huggingface.co → Settings → Access Tokens → New token** (role: **Write**)

Paste the token when prompted. Your credentials are stored locally and persist across sessions.

---

## 4. Create a Repository in the Organisation

Before uploading, you need a repository to upload to. Please use the same name as the github repo. Create one under the organisation with:

```bash
hf repos create AICM-HD/<repo-name> --repo-type model
```

Add `--private` if the repository should not be publicly visible:

```bash
hf repos create AICM-HD/<repo-name> --repo-type model --private
```
---

## 6. Checkpoint Naming Convention

Before uploading, rename checkpoints to make them unambiguous. A clear convention is:

```
{model}_{dataset}.pth
```

For example: `vqgan_chestct.pth`, `ldm_chestct.pth`, etc.

---

## 7. Upload Checkpoints

Replace `<repo>` with the actual repository name on Hugging Face.

**Upload a single file:**

```bash
hf upload AICM-HD/<repo> \
    /path/to/local/checkpoint.pth \
    checkpoint.pth \
    --repo-type model
```

The third argument is the destination filename inside the repository.

**Upload all checkpoints at once from a folder:**

```bash
hf upload AICM-HD/<repo> \
    /path/to/checkpoints/ \
    . \
    --repo-type model
```

This uploads the entire folder contents to the root of the repository.

---

## 8. Verify the Upload

Open the repository in a browser:

```
https://huggingface.co/<org>/<repo>
```

You should see the uploaded files listed under **Files and versions**. Click any file to confirm its size matches the local checkpoint.

You can also verify from the terminal:

```bash
hf repo info AICM-HD/<repo> --repo-type model
```

---

## 9. Downloading Checkpoints

Anyone with access to the repository can download checkpoints with:

```bash
pip install huggingface_hub

hf download AICM-HD/<repo> checkpoint.pth --local-dir checkpoints/
```

Or download everything at once:

```bash
hf download AICM-HD/<repo> --local-dir checkpoints/
```

If the repository is private, members must log in first (`hf auth login`) with their own access token.

---