File size: 1,681 Bytes
9527233
 
 
df13707
 
 
 
9527233
 
df13707
 
9527233
df13707
 
9527233
 
df13707
 
 
 
 
 
 
 
9527233
df13707
9527233
 
 
df13707
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9527233
df13707
 
 
9527233
 
 
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
import os
import subprocess
import sys
import zipfile
import urllib.request
import shutil
from pathlib import Path

def setup_indiclid():
    """Setup IndicLID with proper class file"""
    print("πŸš€ Setting up IndicLID...")
    
    # Create directory structure
    os.makedirs("ai4bharat", exist_ok=True)
    os.makedirs("models", exist_ok=True)
    
    # Create __init__.py
    with open("ai4bharat/__init__.py", "w") as f:
        f.write("# AI4Bharat package\n")
    
    # The IndicLID.py file should be created separately (above)
    # Download model files
    print("πŸ€– Downloading IndicLID models...")
    model_urls = [
        "https://github.com/AI4Bharat/IndicLID/releases/download/v1.0/indiclid-bert.zip",
        "https://github.com/AI4Bharat/IndicLID/releases/download/v1.0/indiclid-ftn.zip",
        "https://github.com/AI4Bharat/IndicLID/releases/download/v1.0/indiclid-ftr.zip"
    ]
    
    current_dir = os.getcwd()
    os.chdir("models")
    
    for url in model_urls:
        filename = url.split("/")[-1]
        print(f"πŸ“₯ Downloading {filename}...")
        try:
            urllib.request.urlretrieve(url, filename)
            print(f"βœ… Downloaded {filename}")
            
            print(f"πŸ“¦ Extracting {filename}...")
            with zipfile.ZipFile(filename, 'r') as zip_ref:
                zip_ref.extractall('.')
            os.remove(filename)
            print(f"βœ… Extracted {filename}")
            
        except Exception as e:
            print(f"❌ Error with {filename}: {e}")
    
    os.chdir(current_dir)
    print("πŸŽ‰ IndicLID setup completed!")
    return True

if __name__ == "__main__":
    setup_indiclid()