Grinding commited on
Commit
fb70c55
·
verified ·
1 Parent(s): 9d15fd1

Delete download_model.py

Browse files
Files changed (1) hide show
  1. download_model.py +0 -47
download_model.py DELETED
@@ -1,47 +0,0 @@
1
- # download_model.py
2
-
3
- import os
4
- import logging
5
- from faster_whisper import WhisperModel
6
-
7
- # Configure logging
8
- logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
9
-
10
- def download_and_convert_model():
11
- """
12
- Downloads and converts the Whisper model to the CTranslate2 format.
13
- The WhisperModel class handles both downloading and conversion.
14
- """
15
- model_name = "distil-whisper/distil-large-v3"
16
- cache_path = os.getenv("HF_HOME", "/data/hf_cache")
17
-
18
- logging.info(f"Starting download and conversion for model: {model_name}")
19
- logging.info(f"Cache directory set to: {cache_path}")
20
-
21
- try:
22
- # Initializing the model will trigger the download and conversion process.
23
- # The converted files, including model.bin, will be stored in the cache_path.
24
- _ = WhisperModel(
25
- model_name,
26
- device="cpu",
27
- compute_type="int8",
28
- download_root=cache_path # This ensures everything is stored in our target directory
29
- )
30
- logging.info("✅ Model downloaded and converted successfully.")
31
-
32
- # Verify that model.bin was created
33
- if os.path.exists(os.path.join(cache_path, "model.bin")):
34
- logging.info("✅ Verification successful: model.bin found.")
35
- else:
36
- # This part of the original log shows the structure if conversion fails/is partial
37
- # a snapshot is downloaded but not the CTranslate2 model.bin
38
- logging.error("❌ Verification failed: model.bin was not created.")
39
- logging.error(f"Cache directory contents: {os.listdir(cache_path)}")
40
- exit(1) # Exit with an error code to fail the Docker build
41
-
42
- except Exception as e:
43
- logging.error(f"❌ An error occurred during model download/conversion: {e}")
44
- exit(1) # Exit with an error code
45
-
46
- if __name__ == "__main__":
47
- download_and_convert_model()