File size: 1,381 Bytes
5792ae0 |
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 |
### Hugging Face CLI Tool
This CLI tool allows you to **upload** and **download** models from Hugging Face repositories. It requires an **Hugging Face Access Token (`HF_TOKEN`)** for authentication, especially for private repositories.
### Prerequisites
1. **Install Hugging Face Hub**:
```bash
pip install huggingface_hub
```
2. **Get HF_TOKEN**:
- Log in to [Hugging Face](https://huggingface.co/).
- Go to **Settings** → **Access Tokens** → **Create a new token** with `read` and `write` permissions.
- Save the token.
### Usage
1. **Set the Token**:
- **Linux/macOS**:
```bash
export HF_TOKEN=your_token_here
```
- **Windows (CMD)**:
```bash
set HF_TOKEN=your_token_here
```
2. **Download Model**:
```bash
python main.py --download --repo-id <repo_name> --save-dir <local_save_path>
```
3. **Upload Model**:
```bash
python main.py --upload --repo-id <repo_name> --model-path <local_model_path>
```
### Example
To download a model:
```bash
python main.py
```
### Authentication
Ensure you set `HF_TOKEN` to access private repositories. If not set, the script will raise an error.
Here’s a clearer and more polished version of that note:
---
### ⚠️ Note
**Make sure to run this script from the `HuggingFace` directory to ensure correct path resolution and functionality.**
---
|