Upload script.py with huggingface_hub
Browse files
script.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub import HfApi
|
2 |
+
|
3 |
+
# Replace with your actual access token (obtain from Hugging Face settings)
|
4 |
+
|
5 |
+
# Set up the Hugging Face API with authentication
|
6 |
+
api = HfApi()
|
7 |
+
|
8 |
+
# Specify the local file path and desired location in the repository
|
9 |
+
# local_file_path = "images.zip"
|
10 |
+
local_file_path = "script.py"
|
11 |
+
path_in_repo = local_file_path
|
12 |
+
|
13 |
+
# Define the repository ID and type
|
14 |
+
repo_id = "umiuni/implant"
|
15 |
+
repo_type = "dataset"
|
16 |
+
|
17 |
+
try:
|
18 |
+
# Upload the file with progress bar feedback
|
19 |
+
upload_result = api.upload_file(
|
20 |
+
path_or_fileobj=local_file_path,
|
21 |
+
path_in_repo=path_in_repo,
|
22 |
+
repo_id=repo_id,
|
23 |
+
repo_type=repo_type,
|
24 |
+
)
|
25 |
+
|
26 |
+
print(f"File uploaded successfully! Link: {upload_result['url']}")
|
27 |
+
except Exception as e:
|
28 |
+
print(f"An error occurred during upload: {e}")
|