| from huggingface_hub import HfApi |
| import os |
| import sys |
|
|
| |
| |
| |
| local_dir = "." |
|
|
| |
| hf_repo_id = "algorythmtechnologies/Syntax-3B-Untrained" |
|
|
| |
| branch_name = "main" |
|
|
| |
|
|
| |
| if len(sys.argv) > 1: |
| token = sys.argv[1] |
| else: |
| print("Error: Hugging Face token not provided.") |
| print("Usage: python push_to_hub.py <your_hf_token>") |
| sys.exit(1) |
|
|
|
|
| print(f"Found local directory: {local_dir}") |
| print("Authenticating with Hugging Face...") |
|
|
| try: |
| |
| api = HfApi(token=token) |
|
|
| print(f"Uploading contents of '{local_dir}' to '{hf_repo_id}' on branch '{branch_name}'...") |
|
|
| |
| api.upload_folder( |
| folder_path=local_dir, |
| repo_id=hf_repo_id, |
| repo_type="model", |
| revision=branch_name, |
| commit_message=f"Upload project folder {local_dir}" |
| ) |
|
|
| print("\nUpload complete!") |
| print(f"You can view your repository at: https://huggingface.co/{hf_repo_id}/tree/{branch_name}") |
|
|
| except Exception as e: |
| print(f"\nAn error occurred: {e}") |