amychensima commited on
Commit
8cfa0fb
·
verified ·
1 Parent(s): a2500b6
gen_models--openai--whisper-small.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #**************************************************************************
2
+ #|| SiMa.ai CONFIDENTIAL ||
3
+ #|| Unpublished Copyright (c) 2025 SiMa.ai, All Rights Reserved. ||
4
+ #**************************************************************************
5
+ # NOTICE: All information contained herein is, and remains the property of
6
+ # SiMa.ai. The intellectual and technical concepts contained herein are
7
+ # proprietary to SiMa and may be covered by U.S. and Foreign Patents,
8
+ # patents in process, and are protected by trade secret or copyright law.
9
+ #
10
+ # Dissemination of this information or reproduction of this material is
11
+ # strictly forbidden unless prior written permission is obtained from
12
+ # SiMa.ai. Access to the source code contained herein is hereby forbidden
13
+ # to anyone except current SiMa.ai employees, managers or contractors who
14
+ # have executed Confidentiality and Non-disclosure agreements explicitly
15
+ # covering such access.
16
+ #
17
+ # The copyright notice above does not evidence any actual or intended
18
+ # publication or disclosure of this source code, which includes information
19
+ # that is confidential and/or proprietary, and is a trade secret, of SiMa.ai.
20
+ #
21
+ # ANY REPRODUCTION, MODIFICATION, DISTRIBUTION, PUBLIC PERFORMANCE, OR PUBLIC
22
+ # DISPLAY OF OR THROUGH USE OF THIS SOURCE CODE WITHOUT THE EXPRESS WRITTEN
23
+ # CONSENT OF SiMa.ai IS STRICTLY PROHIBITED, AND IN VIOLATION OF APPLICABLE
24
+ # LAWS AND INTERNATIONAL TREATIES. THE RECEIPT OR POSSESSION OF THIS SOURCE
25
+ # CODE AND/OR RELATED INFORMATION DOES NOT CONVEY OR IMPLY ANY RIGHTS TO
26
+ # REPRODUCE, DISCLOSE OR DISTRIBUTE ITS CONTENTS, OR TO MANUFACTURE, USE, OR
27
+ # SELL ANYTHING THAT IT MAY DESCRIBE, IN WHOLE OR IN PART.
28
+ #
29
+ #**************************************************************************
30
+
31
+ import logging
32
+
33
+ from pathlib import Path
34
+
35
+ from afe.apis.error_handling_variables import enable_verbose_error_messages
36
+ from sima_lmm.model import FileGenMode, FileGenPrecision, WhisperModel
37
+
38
+
39
+ def gen_files(model_path: Path, num_processes: int, resume: bool):
40
+ enable_verbose_error_messages()
41
+
42
+ model = WhisperModel.from_hf_cache(
43
+ hf_cache_path=model_path,
44
+ model_name=model_path.name,
45
+ onnx_path=Path(f"{model_path.name}/onnx_files"),
46
+ sima_path=Path(f"{model_path.name}/sima_files"),
47
+ use_future_token_mask=True,
48
+ )
49
+
50
+ log_level = logging.INFO
51
+ precision = {
52
+ "encoder": FileGenPrecision.A_BF16_W_INT8,
53
+ "decoder": FileGenPrecision.A_BF16_W_INT8,
54
+ }
55
+ model.gen_files(
56
+ FileGenMode.ALL, precision=precision, log_level=log_level, num_processes=num_processes,
57
+ resume=resume
58
+ )
59
+
60
+
61
+ if __name__ == "__main__":
62
+ import argparse
63
+
64
+ # Download the HuggingFace openai/whisper-small using the following command.
65
+ # huggingface-cli download openai/whisper-small
66
+
67
+ parser = argparse.ArgumentParser(description="Whisper generate file arguments")
68
+ parser.add_argument("--model_path", type=Path, required=True)
69
+ parser.add_argument("--num_processes", type=int, default=1)
70
+ parser.add_argument("--resume", action="store_true", default=False)
71
+ args = parser.parse_args()
72
+ print("Arguments:", args, flush=True)
73
+ gen_files(args.model_path, args.num_processes, args.resume)