File size: 1,117 Bytes
9a84463
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""

Upload script for Hugging Face dataset.

Run this after logging in with: huggingface-cli login

"""

from huggingface_hub import HfApi, create_repo
from pathlib import Path
import os

# Configuration
DATASET_NAME = "anime-characters"
DATASET_DIR = "huggingface_dataset"

def upload_dataset():
    api = HfApi()
    
    # Get username
    username = api.whoami()["name"]
    repo_id = f"{username}/{DATASET_NAME}"
    
    print(f"Creating repository: {repo_id}")
    
    # Create repository
    try:
        create_repo(repo_id, repo_type="dataset", private=False)
        print("Repository created successfully!")
    except Exception as e:
        print(f"Repository might already exist: {e}")
    
    # Upload files
    print("Uploading files...")
    api.upload_folder(
        folder_path=DATASET_DIR,
        repo_id=repo_id,
        repo_type="dataset",
    )
    
    print(f"\nDataset uploaded successfully!")
    print(f"View your dataset at: https://huggingface.co/datasets/{repo_id}")

if __name__ == "__main__":
    upload_dataset()