File size: 1,050 Bytes
8380bda
 
 
 
 
 
 
 
 
3058996
8380bda
 
 
 
3058996
 
 
 
8380bda
 
 
 
3058996
 
 
 
8380bda
 
 
 
 
3058996
8380bda
 
 
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
from huggingface_hub import HfApi
import os

# Replace with your repository details
repo_id = "ericsonwillians/distilbert-base-uncased-steam-sentiment"

# Path to your local directory containing files
local_directory = "./"

# Initialize API
api = HfApi()

# Loop through files and upload them
for root, _, files in os.walk(local_directory):
    # Skip .git directory and other unwanted files
    if ".git" in root:
        continue

    for file in files:
        full_path = os.path.join(root, file)
        relative_path = os.path.relpath(full_path, local_directory)  # Maintain file structure

        # Skip files like README.md if you want to manually edit metadata later
        if relative_path.startswith(".git") or file.endswith(".pyc"):
            continue

        print(f"Uploading {relative_path}...")
        api.upload_file(
            path_or_fileobj=full_path,
            path_in_repo=relative_path,
            repo_id=repo_id,
            repo_type="model"  # Change to "dataset" if needed
        )

print("Upload complete!")