zackli4ai commited on
Commit
2015699
1 Parent(s): 6b63fe7

Create upload_file.py

Browse files
Files changed (1) hide show
  1. upload_file.py +35 -0
upload_file.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from huggingface_hub import HfApi
3
+
4
+ # Initialize HfApi
5
+ api = HfApi()
6
+
7
+ # Define the repository
8
+ repo_id = "NexaAIDev/octopus-v4-gguf"
9
+ repo_type = "model"
10
+
11
+ # Get the list of all files already uploaded in the repo
12
+ existing_files = api.list_repo_files(repo_id=repo_id, repo_type=repo_type)
13
+
14
+ # Directory to check for .gguf files
15
+ local_directory = "./" # Adjust this path as needed
16
+
17
+ # Loop through all .gguf files in the local directory
18
+ for filename in os.listdir(local_directory):
19
+ if filename.endswith(".gguf"):
20
+ # Check if the file is already in the repository
21
+ if filename not in existing_files:
22
+ print(f"Uploading {filename}...")
23
+ api.upload_file(
24
+ path_or_fileobj=os.path.join(local_directory, filename),
25
+ path_in_repo=filename,
26
+ repo_id=repo_id,
27
+ repo_type=repo_type,
28
+ )
29
+ print(f"Uploaded {filename}.")
30
+ else:
31
+ print(f"{filename} already exists in the repository.")
32
+ else:
33
+ print(f"{filename} is not a .gguf file.")
34
+
35
+ print("Operation completed.")