SIngtel-Bill-Scanner / upload_model.py
Cosmo125's picture
Upload 26 files
795183d verified
import os
from huggingface_hub import HfApi
def upload_to_huggingface():
"""Upload the Singtel Bill Scanner to Hugging Face Spaces"""
try:
# Check if token is available
token = os.getenv("HF_TOKEN")
if not token:
print("Error: HF_TOKEN environment variable not set")
print("Please set your Hugging Face token:")
print("$env:HF_TOKEN='your_token_here' # PowerShell")
return False
api = HfApi(token=token)
# Test token validity
try:
user_info = api.whoami()
print(f"βœ… Logged in as: {user_info['name']}")
except Exception as e:
print(f"❌ Invalid token: {e}")
return False
print("πŸš€ Uploading Singtel Bill Scanner to Hugging Face Spaces...")
print("πŸ“ This will create a live web app with your OCR scanner!")
print("🎯 Target space: Singtel_Bill_Scanner")
api.upload_folder(
folder_path="C:/Users/Cosmo/Desktop/Singtel Bill Scanner",
repo_id="Cosmo125/Singtel_Bill_Scanner",
repo_type="space", # Changed to 'space' for web app deployment
ignore_patterns=[
"*.pyc",
"__pycache__/",
".venv/",
"test_*.png",
"test_*.jpg",
"sample_*.jpg",
"*.log",
".git/"
],
commit_message="πŸš€ Deploy Singtel Bill Scanner - Live OCR Web App"
)
print("βœ… Upload completed successfully!")
print("πŸŽ‰ Your Singtel Bill Scanner is now live!")
print("πŸ”— Web App URL: https://huggingface.co/spaces/Cosmo125/Singtel_Bill_Scanner")
print()
print("πŸ“± Features now available:")
print(" - Live web interface for bill scanning")
print(" - Upload images and get instant OCR results")
print(" - Automatic parsing of bill information")
print(" - JSON export functionality")
print()
print("⏰ Note: It may take 2-3 minutes for the app to build")
print("πŸ”„ If you see 'Building...', wait and refresh the page")
return True
except Exception as e:
print(f"❌ Upload failed: {e}")
return False
if __name__ == "__main__":
upload_to_huggingface()