import os from huggingface_hub import HfApi # Define the local folder to upload and the target repository name local_folder_path = "C:/Users/aravi/Desktop/dolphin phi summarizer" repo_id = "cranky-coder08/dolphin-phi-summarizer" # You can change this to your desired repo name # Ensure you are logged in to the Hugging Face Hub # You need to run `huggingface-cli login` in your terminal first. # This command stores your token securely. try: api = HfApi() api.whoami() print("Successfully logged in to Hugging Face.") except Exception as e: print("Please log in to Hugging Face first by running 'huggingface-cli login' in your terminal.") print(f"Error: {e}") exit() # Create the repository if it doesn't already exist try: api.create_repo(repo_id, exist_ok=True, repo_type="model") print(f"Repository '{repo_id}' created or already exists.") except Exception as e: print(f"An error occurred while creating the repository: {e}") exit() # Upload the entire folder to the repository print(f"Uploading folder '{local_folder_path}' to '{repo_id}'...") try: api.upload_large_folder( folder_path=local_folder_path, repo_id=repo_id, repo_type="model", ) print("Upload complete! The folder has been successfully pushed to the Hugging Face Hub.") print(f"You can view your repository here: https://huggingface.co/{repo_id}") except Exception as e: print(f"An error occurred during the upload: {e}")