| from huggingface_hub import HfApi, create_repo | |
| import os | |
| # Get token from environment or input | |
| token = os.getenv("HF_TOKEN") or input("Enter your Hugging Face token: ").strip() | |
| # Configuration | |
| repo_name = "csrnet-keras-crowd-counting" | |
| username = "Adiii2308" | |
| # Create repository | |
| repo_id = f"{username}/{repo_name}" | |
| create_repo(repo_id, exist_ok=True, repo_type="model", token=token) | |
| # Upload files | |
| api = HfApi(token=token) | |
| api.upload_folder( | |
| folder_path=".", | |
| repo_id=repo_id, | |
| repo_type="model", | |
| ignore_patterns=["*.pyc", "__pycache__", ".git", "data/*", ".ipynb_checkpoints/*"] | |
| ) | |
| print(f"Model uploaded to: https://huggingface.co/{repo_id}") | |