File size: 3,343 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"""

Upload to specific Hugging Face Space: singtel_bill_scanner

"""

import os
from huggingface_hub import HfApi

def upload_to_singtel_space():
    """Upload specifically to the singtel_bill_scanner space"""
    
    print("πŸš€ UPLOADING TO SINGTEL_BILL_SCANNER SPACE")
    print("=" * 50)
    
    try:
        # Check token
        token = os.getenv("HF_TOKEN")
        if not token:
            print("❌ HF_TOKEN environment variable not set")
            print("Please set your Hugging Face token first")
            return False
        
        api = HfApi(token=token)
        
        # Verify login
        try:
            user_info = api.whoami()
            print(f"βœ… Logged in as: {user_info['name']}")
        except Exception as e:
            print(f"❌ Token invalid: {e}")
            return False
        
        print("\nπŸ“ Preparing upload...")
        print("🎯 Target: Cosmo125/singtel_bill_scanner")
        print("πŸ“¦ Type: Hugging Face Space (Web App)")
        
        # Upload to the specific space
        api.upload_folder(
            folder_path=".",
            repo_id="Cosmo125/singtel_bill_scanner",
            repo_type="space",
            ignore_patterns=[
                "*.pyc", 
                "__pycache__/", 
                ".venv/", 
                "test_*.png",
                "test_*.jpg", 
                "sample_*.jpg",
                "*.log",
                ".git/",
                "deployment_summary.py",
                "spaces_monitor.py"
            ],
            commit_message="πŸš€ Deploy Singtel Bill Scanner to singtel_bill_scanner space"
        )
        
        print("\nπŸŽ‰ SUCCESS! Upload completed!")
        print("=" * 60)
        print("πŸ”— Your Singtel Bill Scanner is now live at:")
        print("   https://huggingface.co/spaces/Cosmo125/singtel_bill_scanner")
        print()
        print("πŸ“± Space Features:")
        print("   ✨ Live web interface for bill scanning")
        print("   πŸ” Upload bill images and get instant OCR")
        print("   πŸ“Š Automatic parsing of amounts, dates, accounts")
        print("   πŸ’Ύ JSON export of extracted data")
        print("   πŸ”’ Privacy-first (images not stored)")
        print()
        print("⏰ Deployment Timeline:")
        print("   πŸ“€ Upload: COMPLETE βœ…")
        print("   πŸ”¨ Build: 2-3 minutes")
        print("   πŸš€ Live: Ready soon!")
        print()
        print("πŸ’‘ Next Steps:")
        print("   1. Visit the URL above")
        print("   2. Wait for 'Building...' to complete")
        print("   3. Upload a Singtel bill to test!")
        print("=" * 60)
        
        return True
        
    except Exception as e:
        print(f"\n❌ Upload failed: {e}")
        print("\nπŸ”§ Troubleshooting:")
        print("1. Check internet connection")
        print("2. Verify HF token permissions")
        print("3. Ensure space name is available")
        return False

if __name__ == "__main__":
    success = upload_to_singtel_space()
    
    if success:
        print("\n🎯 Ready to go! Check the URL above in 2-3 minutes.")
    else:
        print("\n❌ Upload failed. Check the error messages above.")
    
    input("\nPress Enter to exit...")