|
|
|
|
|
""" |
|
|
Git-based Hugging Face upload for Bengali AI model |
|
|
Repository: megharudushi/Sheikh |
|
|
""" |
|
|
|
|
|
import os |
|
|
import subprocess |
|
|
|
|
|
def git_upload_bengali_ai(): |
|
|
"""Upload using Git commands""" |
|
|
|
|
|
print("🚀 Git-based Hugging Face Upload") |
|
|
print("=" * 40) |
|
|
print("Repository: megharudushi/Sheikh") |
|
|
|
|
|
|
|
|
if not os.path.exists("ready_bengali_ai"): |
|
|
print("❌ Error: ready_bengali_ai directory not found!") |
|
|
return False |
|
|
|
|
|
|
|
|
files = os.listdir("ready_bengali_ai") |
|
|
print(f"\n📁 Files to upload ({len(files)} total):") |
|
|
for file in sorted(files): |
|
|
size = os.path.getsize(f"ready_bengali_ai/{file}") / (1024*1024) |
|
|
print(f" 📄 {file} ({size:.1f}MB)") |
|
|
|
|
|
print("\n" + "="*50) |
|
|
print("🔧 Git-based upload requires:") |
|
|
print("1. git-xet installed") |
|
|
print("2. SSH key configured") |
|
|
print("3. Repository access permissions") |
|
|
print("="*50) |
|
|
|
|
|
try: |
|
|
|
|
|
print("\n📦 Checking git-xet installation...") |
|
|
try: |
|
|
result = subprocess.run(["git", "xet", "--version"], capture_output=True, text=True) |
|
|
if result.returncode == 0: |
|
|
print("✅ git-xet already installed") |
|
|
print(f"Version: {result.stdout.strip()}") |
|
|
else: |
|
|
print("⚠️ git-xet not found, attempting install...") |
|
|
subprocess.run(["pip", "install", "git-xet"], check=True) |
|
|
print("✅ git-xet installed") |
|
|
except Exception as e: |
|
|
print(f"❌ git-xet install failed: {e}") |
|
|
print("Please install manually: https://hf.co/docs/hub/git-xet") |
|
|
|
|
|
|
|
|
print("\n📥 Cloning repository...") |
|
|
repo_url = "git@hf.co:megharudushi/Sheikh" |
|
|
|
|
|
try: |
|
|
|
|
|
if os.path.exists("Sheikh"): |
|
|
subprocess.run(["rm", "-rf", "Sheikh"], check=True) |
|
|
|
|
|
|
|
|
result = subprocess.run(["git", "clone", repo_url], capture_output=True, text=True) |
|
|
if result.returncode == 0: |
|
|
print("✅ Repository cloned successfully") |
|
|
else: |
|
|
print(f"❌ Clone failed: {result.stderr}") |
|
|
print("This might mean:") |
|
|
print("- Repository doesn't exist yet") |
|
|
print("- SSH key not configured") |
|
|
print("- No access permissions") |
|
|
return False |
|
|
|
|
|
except Exception as e: |
|
|
print(f"❌ Repository clone error: {e}") |
|
|
return False |
|
|
|
|
|
|
|
|
print("\n📤 Copying model files...") |
|
|
try: |
|
|
|
|
|
for file in os.listdir("ready_bengali_ai"): |
|
|
src = f"ready_bengali_ai/{file}" |
|
|
dst = f"Sheikh/{file}" |
|
|
subprocess.run(["cp", src, dst], check=True) |
|
|
print(f"✅ Copied {len(files)} files") |
|
|
except Exception as e: |
|
|
print(f"❌ File copy failed: {e}") |
|
|
return False |
|
|
|
|
|
|
|
|
print("\n📤 Committing and pushing...") |
|
|
try: |
|
|
os.chdir("Sheikh") |
|
|
|
|
|
|
|
|
subprocess.run(["git", "add", "."], check=True) |
|
|
|
|
|
|
|
|
commit_message = "Add complete Bengali AI model - 355M parameters with tokenizer" |
|
|
subprocess.run(["git", "commit", "-m", commit_message], check=True) |
|
|
|
|
|
|
|
|
print("📤 Pushing to Hugging Face...") |
|
|
subprocess.run(["git", "push"], check=True) |
|
|
|
|
|
print("\n🎉 SUCCESS! Model uploaded via Git!") |
|
|
print("🌐 Repository: https://huggingface.co/megharudushi/Sheikh") |
|
|
|
|
|
return True |
|
|
|
|
|
except subprocess.CalledProcessError as e: |
|
|
print(f"❌ Git operation failed: {e}") |
|
|
print("\n🔧 Manual steps needed:") |
|
|
print("1. Configure SSH key: https://huggingface.co/settings/keys") |
|
|
print("2. Ensure repository access") |
|
|
print("3. Run: git push") |
|
|
return False |
|
|
|
|
|
except Exception as e: |
|
|
print(f"❌ Upload failed: {e}") |
|
|
return False |
|
|
|
|
|
def create_manual_instructions(): |
|
|
"""Create manual upload instructions""" |
|
|
|
|
|
instructions = """# Manual Git Upload Instructions |
|
|
|
|
|
## Prerequisites |
|
|
1. **Install git-xet**: https://hf.co/docs/hub/git-xet |
|
|
2. **Configure SSH key**: https://huggingface.co/settings/keys |
|
|
3. **Repository access**: Ensure you have write access to megharudushi/Sheikh |
|
|
|
|
|
## Manual Commands |
|
|
```bash |
|
|
# 1. Clone repository |
|
|
git clone git@hf.co:megharudushi/Sheikh |
|
|
|
|
|
# 2. Copy model files |
|
|
cp ready_bengali_ai/* Sheikh/ |
|
|
|
|
|
# 3. Commit and push |
|
|
cd Sheikh |
|
|
git add . |
|
|
git commit -m "Add Bengali AI model - 355M parameters" |
|
|
git push |
|
|
``` |
|
|
|
|
|
## Files to Upload |
|
|
- model.bin (1.4GB) - Model weights |
|
|
- tokenizer.json (3.4MB) - Tokenizer config |
|
|
- vocab.json (780KB) - Vocabulary |
|
|
- config.json (13KB) - Model config |
|
|
- README.md - Model documentation |
|
|
- And 6 other configuration files |
|
|
|
|
|
## After Upload |
|
|
Your model will be available at: |
|
|
https://huggingface.co/megharudushi/Sheikh |
|
|
""" |
|
|
|
|
|
with open("MANUAL_GIT_UPLOAD.md", "w", encoding="utf-8") as f: |
|
|
f.write(instructions) |
|
|
|
|
|
print("📄 Created manual instructions: MANUAL_GIT_UPLOAD.md") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
print("🇧🇩 BANGLI AI - GIT UPLOAD") |
|
|
print("=" * 35) |
|
|
|
|
|
|
|
|
create_manual_instructions() |
|
|
|
|
|
|
|
|
success = git_upload_bengali_ai() |
|
|
|
|
|
if success: |
|
|
print("\n🎊 Git upload successful!") |
|
|
print("Your Bengali AI is now live on Hugging Face!") |
|
|
else: |
|
|
print("\n⚠️ Git upload requires manual setup.") |
|
|
print("Please follow the manual instructions in MANUAL_GIT_UPLOAD.md") |
|
|
print("Or use the Python API approach instead.") |