| """Upload trained model to Hugging Face Hub.""" | |
| import os | |
| from dotenv import load_dotenv | |
| from huggingface_hub import HfApi, login | |
| # Load environment variables | |
| load_dotenv() | |
| # Login with your token | |
| print("π Logging in to Hugging Face Hub...") | |
| token = os.getenv("HF_TOKEN") | |
| if not token: | |
| raise ValueError("HF_TOKEN not found in .env file") | |
| login(token=token) | |
| print("β Login successful!") | |
| # Upload model | |
| print("π€ Uploading model to dpratapx/restaurant-inspector...") | |
| api = HfApi() | |
| api.create_repo( | |
| repo_id="dpratapx/restaurant-inspector", | |
| repo_type="model", | |
| exist_ok=True, | |
| private=False, | |
| ) | |
| api.upload_folder( | |
| folder_path="./model", | |
| repo_id="dpratapx/restaurant-inspector", | |
| repo_type="model", | |
| ) | |
| print("β Model uploaded successfully!") | |
| print("π View at: https://huggingface.co/dpratapx/restaurant-inspector") | |