Noumida commited on
Commit
df13707
Β·
verified Β·
1 Parent(s): 147c20a

Update setup.py

Browse files
Files changed (1) hide show
  1. setup.py +38 -18
setup.py CHANGED
@@ -1,34 +1,54 @@
1
  import os
2
  import subprocess
3
  import sys
 
 
 
 
4
 
5
  def setup_indiclid():
6
- """Setup IndicLID models"""
 
7
 
8
- print("Setting up IndicLID...")
9
-
10
- # Create directories
11
  os.makedirs("models", exist_ok=True)
12
- os.chdir("models")
13
 
14
- # Download models
15
- models = [
 
 
 
 
 
 
16
  "https://github.com/AI4Bharat/IndicLID/releases/download/v1.0/indiclid-bert.zip",
17
- "https://github.com/AI4Bharat/IndicLID/releases/download/v1.0/indiclid-ftn.zip",
18
  "https://github.com/AI4Bharat/IndicLID/releases/download/v1.0/indiclid-ftr.zip"
19
  ]
20
 
21
- for model_url in models:
22
- filename = model_url.split("/")[-1]
23
- print(f"Downloading {filename}...")
24
- subprocess.run(["wget", "-q", model_url], check=True)
25
-
26
- print(f"Extracting {filename}...")
27
- subprocess.run(["unzip", "-q", filename], check=True)
28
- subprocess.run(["rm", filename], check=True)
 
 
 
 
 
 
 
 
 
 
29
 
30
- os.chdir("..")
31
- print("βœ… IndicLID setup complete")
 
32
 
33
  if __name__ == "__main__":
34
  setup_indiclid()
 
1
  import os
2
  import subprocess
3
  import sys
4
+ import zipfile
5
+ import urllib.request
6
+ import shutil
7
+ from pathlib import Path
8
 
9
  def setup_indiclid():
10
+ """Setup IndicLID with proper class file"""
11
+ print("πŸš€ Setting up IndicLID...")
12
 
13
+ # Create directory structure
14
+ os.makedirs("ai4bharat", exist_ok=True)
 
15
  os.makedirs("models", exist_ok=True)
 
16
 
17
+ # Create __init__.py
18
+ with open("ai4bharat/__init__.py", "w") as f:
19
+ f.write("# AI4Bharat package\n")
20
+
21
+ # The IndicLID.py file should be created separately (above)
22
+ # Download model files
23
+ print("πŸ€– Downloading IndicLID models...")
24
+ model_urls = [
25
  "https://github.com/AI4Bharat/IndicLID/releases/download/v1.0/indiclid-bert.zip",
26
+ "https://github.com/AI4Bharat/IndicLID/releases/download/v1.0/indiclid-ftn.zip",
27
  "https://github.com/AI4Bharat/IndicLID/releases/download/v1.0/indiclid-ftr.zip"
28
  ]
29
 
30
+ current_dir = os.getcwd()
31
+ os.chdir("models")
32
+
33
+ for url in model_urls:
34
+ filename = url.split("/")[-1]
35
+ print(f"πŸ“₯ Downloading {filename}...")
36
+ try:
37
+ urllib.request.urlretrieve(url, filename)
38
+ print(f"βœ… Downloaded {filename}")
39
+
40
+ print(f"πŸ“¦ Extracting {filename}...")
41
+ with zipfile.ZipFile(filename, 'r') as zip_ref:
42
+ zip_ref.extractall('.')
43
+ os.remove(filename)
44
+ print(f"βœ… Extracted {filename}")
45
+
46
+ except Exception as e:
47
+ print(f"❌ Error with {filename}: {e}")
48
 
49
+ os.chdir(current_dir)
50
+ print("πŸŽ‰ IndicLID setup completed!")
51
+ return True
52
 
53
  if __name__ == "__main__":
54
  setup_indiclid()