indic-lid_trans2 / setup.py
Noumida's picture
Update setup.py
df13707 verified
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()