| |
| """ |
| Non-interactive Hugging Face upload |
| Uses environment variable HF_TOKEN |
| Repository: megharudushi/Sheikh |
| """ |
|
|
| import os |
| import sys |
| from huggingface_hub import login, upload_folder, HfApi |
|
|
| def non_interactive_upload(): |
| """Upload model using environment token""" |
| |
| print("🚀 Non-interactive Hugging Face Upload") |
| print("=" * 45) |
| print("Repository: megharudushi/Sheikh") |
| |
| |
| if not os.path.exists("ready_bengali_ai"): |
| print("❌ Error: ready_bengali_ai directory not found!") |
| return False |
| |
| |
| token = os.environ.get('HF_TOKEN') |
| if not token: |
| print("❌ No HF_TOKEN environment variable found!") |
| print("\n🔧 Set your token:") |
| print("export HF_TOKEN=your_token_here") |
| print("Or add to script: os.environ['HF_TOKEN'] = 'your_token'") |
| return False |
| |
| print(f"✅ Using token: {token[:8]}...") |
| |
| try: |
| |
| api = HfApi(token=token) |
| |
| |
| files = os.listdir("ready_bengali_ai") |
| print(f"\n📁 Files to upload ({len(files)} total):") |
| total_size = 0 |
| for file in sorted(files): |
| size = os.path.getsize(f"ready_bengali_ai/{file}") / (1024*1024) |
| total_size += size |
| print(f" 📄 {file} ({size:.1f}MB)") |
| print(f"📊 Total size: {total_size:.1f}MB") |
| |
| |
| print(f"\n📤 Uploading to megharudushi/Sheikh...") |
| upload_folder( |
| folder_path="ready_bengali_ai", |
| repo_id="megharudushi/Sheikh", |
| repo_type="model", |
| commit_message="Complete Bengali AI model - 355M parameters with tokenizer" |
| ) |
| |
| print("\n🎉 SUCCESS!") |
| print("🌐 Your model: https://huggingface.co/megharudushi/Sheikh") |
| print("\n💡 Usage:") |
| print("from transformers import AutoTokenizer, AutoModelForCausalLM") |
| print('tokenizer = AutoTokenizer.from_pretrained("megharudushi/Sheikh")') |
| print('model = AutoModelForCausalLM.from_pretrained("megharudushi/Sheikh")') |
| |
| return True |
| |
| except Exception as e: |
| print(f"❌ Upload failed: {e}") |
| return False |
|
|
| def add_token_to_script(): |
| """Add token directly to script (for testing)""" |
| print("\n🔧 To add token directly to this script:") |
| print("1. Get your token from: https://huggingface.co/settings/tokens") |
| print("2. Add this line at the top of the script:") |
| print(" os.environ['HF_TOKEN'] = 'your_token_here'") |
| print("3. Run: python3 non_interactive_upload.py") |
|
|
| if __name__ == "__main__": |
| print("🇧🇩 BANGLI AI - NON-INTERACTIVE UPLOAD") |
| print("=" * 42) |
| |
| |
| success = non_interactive_upload() |
| |
| if not success: |
| add_token_to_script() |
| print("\n📖 See COMPLETE_UPLOAD_GUIDE.md for all upload methods") |
| else: |
| print("\n🎊 Your Bengali AI model is now live!") |