SIngtel-Bill-Scanner / auto_upload.py
Cosmo125's picture
Upload 26 files
795183d verified
"""
Auto-upload script that automatically proceeds with upload
"""
import os
from huggingface_hub import HfApi
def auto_upload():
"""Automatically upload to Hugging Face"""
print("πŸš€ AUTO-UPLOADING TO HUGGING FACE")
print("=" * 50)
try:
token = os.getenv("HF_TOKEN")
if not token:
print("❌ HF_TOKEN not found")
print("Please run: hf_upload.py to set up your token first")
return False
api = HfApi(token=token)
# Test token
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πŸ“ Creating model card...")
# Create README.md
readme_content = """---
title: Singtel Bill Scanner
emoji: πŸ“±
colorFrom: red
colorTo: orange
sdk: streamlit
sdk_version: 1.28.0
app_file: app.py
pinned: false
tags:
- computer-vision
- ocr
- trocr
- bill-processing
- singtel
- document-ai
---
# Singtel Bill Scanner πŸ“±πŸ’‘
An AI-powered optical character recognition (OCR) system specifically designed for processing Singtel telecommunications bills.
## πŸš€ Try the Live Demo
Upload your Singtel bill image and get instant results!
## Features
- πŸ” **Text Extraction**: Uses Microsoft TrOCR for accurate OCR
- πŸ“Š **Bill Parsing**: Extracts amounts, dates, account numbers
- ⚑ **Fast Processing**: Real-time results
- 🎯 **Singtel Optimized**: Tailored for Singtel bill formats
- πŸ”’ **Privacy First**: Images processed locally, not stored
## How to Use
1. πŸ“Έ Take a clear photo of your Singtel bill
2. πŸ“€ Upload the image using the interface above
3. πŸ” Click "Extract Information"
4. πŸ“Š View the extracted data
## Technical Details
- **Model**: Microsoft TrOCR (microsoft/trocr-base-handwritten)
- **Framework**: Streamlit + Hugging Face Transformers
- **Processing**: ~3-5 seconds per image
- **Accuracy**: High for clear, well-lit images
## Local Installation
```bash
git clone https://huggingface.co/spaces/Cosmo125/Singtel_Bill_Scanner
cd Singtel_Bill_Scanner
pip install -r requirements.txt
streamlit run app.py
```
## API Usage
```python
from transformers import pipeline
from PIL import Image
# Load model
pipe = pipeline("image-to-text", model="microsoft/trocr-base-handwritten")
# Process image
image = Image.open("bill.jpg")
result = pipe(image)
text = result[0]['generated_text']
```
---
*Created for the Singtel community with ❀️*
"""
with open("README.md", "w", encoding="utf-8") as f:
f.write(readme_content)
print("βœ… README.md created")
print("\nπŸ“€ Starting upload to Hugging Face Spaces...")
print("⏳ This may take a few minutes...")
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",
".git/",
"*.log"
],
commit_message="πŸš€ Deploy Singtel Bill Scanner - AI OCR Web App"
)
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("πŸ“± Features available:")
print(" - Live web interface for bill scanning")
print(" - AI-powered text extraction")
print(" - Real-time bill parsing")
print(" - JSON export functionality")
print()
print("⏰ Note: It may take 2-3 minutes for the app to build and become available")
print("πŸ”„ If you see 'Building...', just wait and refresh the page")
print("=" * 60)
return True
except Exception as e:
print(f"❌ Upload failed: {e}")
print("\nπŸ”§ Common solutions:")
print("1. Check your internet connection")
print("2. Verify HF token has write permissions")
print("3. Try again in a few minutes")
return False
if __name__ == "__main__":
auto_upload()