File size: 782 Bytes
bd9d222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from huggingface_hub import HfApi

# Replace with your actual access token (obtain from Hugging Face settings)

# Set up the Hugging Face API with authentication
api = HfApi()

# Specify the local file path and desired location in the repository
# local_file_path = "images.zip"
local_file_path = "script.py"
path_in_repo = local_file_path

# Define the repository ID and type
repo_id = "umiuni/implant"
repo_type = "dataset"

try:
  # Upload the file with progress bar feedback
  upload_result = api.upload_file(
      path_or_fileobj=local_file_path,
      path_in_repo=path_in_repo,
      repo_id=repo_id,
      repo_type=repo_type,
  )

  print(f"File uploaded successfully! Link: {upload_result['url']}")
except Exception as e:
  print(f"An error occurred during upload: {e}")