imbecome commited on
Commit
81e121c
·
verified ·
1 Parent(s): b5974f4

Update download_models.py

Browse files
Files changed (1) hide show
  1. download_models.py +8 -12
download_models.py CHANGED
@@ -4,7 +4,6 @@ import sys
4
  # ==========================
5
  # HUGGINGFACE AUTH
6
  # ==========================
7
-
8
  from huggingface_hub import login
9
 
10
  token = os.getenv("HF_TOKEN")
@@ -18,7 +17,7 @@ else:
18
  # ==========================
19
  # CACHE DIR
20
  # ==========================
21
-
22
  CACHE_DIR = "/home/user/app/models_cache"
23
  os.makedirs(CACHE_DIR, exist_ok=True)
24
 
@@ -27,22 +26,22 @@ print("DOWNLOADING AI MODELS")
27
  print("================================")
28
 
29
  # ==========================
30
- # WHISPER MODEL
31
  # ==========================
32
-
33
  try:
34
  from faster_whisper import WhisperModel
35
 
36
- print("Downloading Whisper tiny model...")
 
37
 
38
  WhisperModel(
39
- "tiny",
40
  device="cpu",
41
  compute_type="int8",
42
  download_root=CACHE_DIR
43
  )
44
 
45
- print("Whisper download complete")
46
 
47
  except Exception as e:
48
  print("WHISPER ERROR:", e)
@@ -51,16 +50,13 @@ except Exception as e:
51
  # ==========================
52
  # DISTILBERT SENTIMENT
53
  # ==========================
54
-
55
  try:
56
- from transformers import AutoTokenizer
57
- from transformers import AutoModelForSequenceClassification
58
 
59
  model_name = "distilbert-base-uncased-finetuned-sst-2-english"
60
-
61
  save_path = os.path.join(CACHE_DIR, "distilbert")
62
 
63
- print("Downloading DistilBERT...")
64
 
65
  tokenizer = AutoTokenizer.from_pretrained(model_name)
66
  model = AutoModelForSequenceClassification.from_pretrained(model_name)
 
4
  # ==========================
5
  # HUGGINGFACE AUTH
6
  # ==========================
 
7
  from huggingface_hub import login
8
 
9
  token = os.getenv("HF_TOKEN")
 
17
  # ==========================
18
  # CACHE DIR
19
  # ==========================
20
+ # Sinkronkan dengan CACHE_DIR di app.py (Canvas)
21
  CACHE_DIR = "/home/user/app/models_cache"
22
  os.makedirs(CACHE_DIR, exist_ok=True)
23
 
 
26
  print("================================")
27
 
28
  # ==========================
29
+ # WHISPER MODEL (UPGRADED TO BASE)
30
  # ==========================
 
31
  try:
32
  from faster_whisper import WhisperModel
33
 
34
+ # Mengubah "tiny" menjadi "base" sesuai kebutuhan app.py terbaru
35
+ print("Downloading Whisper BASE model (Better Accuracy)...")
36
 
37
  WhisperModel(
38
+ "base",
39
  device="cpu",
40
  compute_type="int8",
41
  download_root=CACHE_DIR
42
  )
43
 
44
+ print("Whisper BASE download complete")
45
 
46
  except Exception as e:
47
  print("WHISPER ERROR:", e)
 
50
  # ==========================
51
  # DISTILBERT SENTIMENT
52
  # ==========================
 
53
  try:
54
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
 
55
 
56
  model_name = "distilbert-base-uncased-finetuned-sst-2-english"
 
57
  save_path = os.path.join(CACHE_DIR, "distilbert")
58
 
59
+ print(f"Downloading {model_name}...")
60
 
61
  tokenizer = AutoTokenizer.from_pretrained(model_name)
62
  model = AutoModelForSequenceClassification.from_pretrained(model_name)