"""Upload this prepared model repository to Hugging Face Hub. Usage: HF_TOKEN=... python upload_to_hub.py --repo-id USER_OR_ORG/REPO_NAME The token is read from the environment by huggingface_hub. Do not hard-code it. """ from __future__ import annotations import argparse from pathlib import Path from huggingface_hub import HfApi def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser(description="Upload model repository to Hugging Face Hub.") parser.add_argument("--repo-id", required=True, help="Target model repo, e.g. username/yazlab6-car-body-classifier") parser.add_argument("--repo-dir", default=".", help="Local prepared repo directory") parser.add_argument("--private", action="store_true", help="Create or keep the Hub repo private") return parser.parse_args() def main() -> None: args = parse_args() repo_dir = Path(args.repo_dir).resolve() api = HfApi() api.create_repo(repo_id=args.repo_id, repo_type="model", private=args.private, exist_ok=True) api.upload_folder( repo_id=args.repo_id, repo_type="model", folder_path=repo_dir, ignore_patterns=[ "__pycache__/**", "*.pyc", ".git/**", ".env*", "*.log", ], ) if __name__ == "__main__": main()