直接使用以下代码:
!pip install huggingface_hub
from huggingface_hub import HfApi
from huggingface_hub.utils import validate_repo_id
api = HfApi()
# Replace with your Hugging Face token and desired repo ID
token = "******"
repo_id = "*************"
# Validate the repo ID
try:
validate_repo_id(repo_id)
except ValueError as e:
print(e)
# Upload the first model folder
api.upload_folder(
folder_path="/content/model",
repo_id=repo_id,
repo_type="model",
token=token
)
# Upload the second model folder
api.upload_folder(
folder_path="/content/drive/MyDrive/llama3.1",
repo_id=repo_id,
repo_type="model",
token=token
)
print("Models uploaded to Hugging Face Hub.")