File size: 3,079 Bytes
7d3d63c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
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")
    
    # Check model directory
    if not os.path.exists("ready_bengali_ai"):
        print("❌ Error: ready_bengali_ai directory not found!")
        return False
    
    # Check authentication token
    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:
        # Initialize API with token
        api = HfApi(token=token)
        
        # Show files to upload
        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")
        
        # Upload files
        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)
    
    # Try upload
    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!")