| import os | |
| from huggingface_hub import HfApi, create_repo | |
| # Configuration | |
| REPO_NAME = "Bird-vs-Drone-image-classification-using-Deep-Learning" | |
| USERNAME = "d-e-e-k-11" # Your Hugging Face username | |
| REPO_ID = f"{USERNAME}/{REPO_NAME}" | |
| api = HfApi() | |
| def upload(): | |
| print(f"Starting upload to https://huggingface.co/spaces/{REPO_ID}") | |
| try: | |
| # 1. Create the repo if it doesn't exist | |
| print(f"Checking if repo {REPO_ID} exists...") | |
| create_repo( | |
| repo_id=REPO_ID, | |
| repo_type="space", | |
| space_sdk="docker", | |
| exist_ok=True | |
| ) | |
| # 2. Define files to ignore | |
| # We explicitly exclude the 41k+ images in Dataset/ to avoid hashing crashes | |
| ignore_patterns = [ | |
| "Dataset/**/*", | |
| "Dataset/*", | |
| "data/**/*", | |
| "data/*", | |
| ".git/**/*", | |
| ".git/*", | |
| "__pycache__/**/*", | |
| "*.pyc", | |
| "training_history.png", | |
| "history.json" | |
| ] | |
| # 3. Use upload_folder (which handles multi-part uploads for large files internally) | |
| print("Uploading project files (skipping large datasets)...") | |
| api.upload_folder( | |
| folder_path=".", | |
| repo_id=REPO_ID, | |
| repo_type="space", | |
| ignore_patterns=ignore_patterns | |
| ) | |
| print(f"\nSuccess! Your app is live at: https://huggingface.co/spaces/{REPO_ID}") | |
| print("The build process will start automatically.") | |
| except Exception as e: | |
| print(f"\nError: {e}") | |
| print("\nIf you are not logged in, run: huggingface-cli login") | |
| if __name__ == "__main__": | |
| upload() | |