rinmokudi12 commited on
Commit
c06dba8
·
verified ·
1 Parent(s): ca6d5d9

Create download_models.py

Browse files
Files changed (1) hide show
  1. download_models.py +52 -0
download_models.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Pre-download models during Docker build to reduce startup time
4
+ """
5
+ import os
6
+ import sys
7
+
8
+ def download_whisper():
9
+ """Download Whisper Large v3"""
10
+ print("🔥 Downloading Whisper Large v3...")
11
+ import whisper
12
+ model = whisper.load_model("large-v3")
13
+ print("✅ Whisper ready")
14
+ return model
15
+
16
+ def download_sealion():
17
+ """Download Sea-Lion 7B (placeholder - replace with 27B if available)"""
18
+ print("🔥 Downloading Sea-Lion...")
19
+ from transformers import AutoTokenizer, AutoModelForCausalLM
20
+ import torch
21
+
22
+ model_name = "aisingapore/sea-lion-7b-instruct"
23
+
24
+ try:
25
+ tokenizer = AutoTokenizer.from_pretrained(
26
+ model_name,
27
+ trust_remote_code=True,
28
+ cache_dir="/app/models"
29
+ )
30
+ model = AutoModelForCausalLM.from_pretrained(
31
+ model_name,
32
+ torch_dtype=torch.float16,
33
+ device_map="auto",
34
+ trust_remote_code=True,
35
+ cache_dir="/app/models"
36
+ )
37
+ print("✅ Sea-Lion ready")
38
+ return model, tokenizer
39
+ except Exception as e:
40
+ print(f"⚠️ Could not download Sea-Lion: {e}")
41
+ print("Will attempt on startup")
42
+ return None, None
43
+
44
+ if __name__ == "__main__":
45
+ try:
46
+ download_whisper()
47
+ download_sealion()
48
+ print("🎉 All models pre-downloaded!")
49
+ except Exception as e:
50
+ print(f"⚠️ Pre-download incomplete: {e}")
51
+ sys.exit(0) # Don't fail build
52
+