ericsonwillians commited on
Commit
3058996
·
verified ·
1 Parent(s): 8380bda

Upload upload_repo.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. upload_repo.py +10 -2
upload_repo.py CHANGED
@@ -7,21 +7,29 @@ repo_id = "ericsonwillians/distilbert-base-uncased-steam-sentiment"
7
  # Path to your local directory containing files
8
  local_directory = "./"
9
 
10
- # Initialize API and login (assumes you’re already logged in)
11
  api = HfApi()
12
 
13
  # Loop through files and upload them
14
  for root, _, files in os.walk(local_directory):
 
 
 
 
15
  for file in files:
16
  full_path = os.path.join(root, file)
17
  relative_path = os.path.relpath(full_path, local_directory) # Maintain file structure
18
 
 
 
 
 
19
  print(f"Uploading {relative_path}...")
20
  api.upload_file(
21
  path_or_fileobj=full_path,
22
  path_in_repo=relative_path,
23
  repo_id=repo_id,
24
- repo_type="model" # Change to "dataset" if it's a dataset repository
25
  )
26
 
27
  print("Upload complete!")
 
7
  # Path to your local directory containing files
8
  local_directory = "./"
9
 
10
+ # Initialize API
11
  api = HfApi()
12
 
13
  # Loop through files and upload them
14
  for root, _, files in os.walk(local_directory):
15
+ # Skip .git directory and other unwanted files
16
+ if ".git" in root:
17
+ continue
18
+
19
  for file in files:
20
  full_path = os.path.join(root, file)
21
  relative_path = os.path.relpath(full_path, local_directory) # Maintain file structure
22
 
23
+ # Skip files like README.md if you want to manually edit metadata later
24
+ if relative_path.startswith(".git") or file.endswith(".pyc"):
25
+ continue
26
+
27
  print(f"Uploading {relative_path}...")
28
  api.upload_file(
29
  path_or_fileobj=full_path,
30
  path_in_repo=relative_path,
31
  repo_id=repo_id,
32
+ repo_type="model" # Change to "dataset" if needed
33
  )
34
 
35
  print("Upload complete!")