File size: 2,486 Bytes
795183d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
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()
|