|
import os
|
|
from huggingface_hub import HfApi
|
|
|
|
def upload_to_huggingface():
|
|
"""Upload the Singtel Bill Scanner to Hugging Face Spaces"""
|
|
try:
|
|
|
|
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)
|
|
|
|
|
|
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",
|
|
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()
|
|
|