Spaces:
Running
Running
Update modules/app.py
Browse files- modules/app.py +10 -9
modules/app.py
CHANGED
@@ -63,7 +63,7 @@ def load_models():
|
|
63 |
#'nllb-1.3B': 'facebook/nllb-200-1.3B',
|
64 |
#'nllb-distilled-1.3B': 'facebook/nllb-200-distilled-1.3B',
|
65 |
#'nllb-3.3B': 'facebook/nllb-200-3.3B',
|
66 |
-
'nllb-moe-54b': 'facebook/nllb-moe-54b',
|
67 |
}
|
68 |
|
69 |
model_dict = {}
|
@@ -82,31 +82,32 @@ def load_models():
|
|
82 |
beam_size = 1 # change to a smaller value for faster inference
|
83 |
device = "cpu" # or "cuda"
|
84 |
|
|
|
|
|
85 |
# Language Prediction model
|
86 |
-
print("\
|
87 |
lang_model_file = "lid218e.bin"
|
88 |
lang_model_full_path = os.path.join(os.path.dirname(__file__), lang_model_file)
|
89 |
lang_model = fasttext.load_model(lang_model_full_path)
|
90 |
|
91 |
|
92 |
# Load the source SentencePiece model
|
93 |
-
print("\
|
94 |
sp_model_file = "spm.model"
|
95 |
sp_model_full_path = os.path.join(os.path.dirname(__file__), sp_model_file)
|
96 |
sp = spm.SentencePieceProcessor()
|
97 |
sp.load(sp_model_full_path)
|
98 |
|
99 |
# Import The Translator model
|
100 |
-
|
101 |
-
print("\
|
102 |
ct_model_file = "sematrans-3.3B"
|
103 |
ct_model_full_path = os.path.join(os.path.dirname(__file__), ct_model_file)
|
104 |
translator = ctranslate2.Translator(ct_model_full_path, device)
|
105 |
-
'''
|
106 |
-
print("\nimporting Translator model")
|
107 |
-
model_dict = load_models()
|
108 |
|
109 |
-
|
|
|
|
|
110 |
|
111 |
|
112 |
def translate_detect(userinput: str, target_lang: str):
|
|
|
63 |
#'nllb-1.3B': 'facebook/nllb-200-1.3B',
|
64 |
#'nllb-distilled-1.3B': 'facebook/nllb-200-distilled-1.3B',
|
65 |
#'nllb-3.3B': 'facebook/nllb-200-3.3B',
|
66 |
+
#'nllb-moe-54b': 'facebook/nllb-moe-54b',
|
67 |
}
|
68 |
|
69 |
model_dict = {}
|
|
|
82 |
beam_size = 1 # change to a smaller value for faster inference
|
83 |
device = "cpu" # or "cuda"
|
84 |
|
85 |
+
print('(note-to-self)..... I play the Orchestra🦋.......')
|
86 |
+
|
87 |
# Language Prediction model
|
88 |
+
print("\n1️⃣importing Language Prediction model")
|
89 |
lang_model_file = "lid218e.bin"
|
90 |
lang_model_full_path = os.path.join(os.path.dirname(__file__), lang_model_file)
|
91 |
lang_model = fasttext.load_model(lang_model_full_path)
|
92 |
|
93 |
|
94 |
# Load the source SentencePiece model
|
95 |
+
print("\n2️⃣importing SentencePiece model")
|
96 |
sp_model_file = "spm.model"
|
97 |
sp_model_full_path = os.path.join(os.path.dirname(__file__), sp_model_file)
|
98 |
sp = spm.SentencePieceProcessor()
|
99 |
sp.load(sp_model_full_path)
|
100 |
|
101 |
# Import The Translator model
|
102 |
+
|
103 |
+
print("\n3️⃣importing Translator model")
|
104 |
ct_model_file = "sematrans-3.3B"
|
105 |
ct_model_full_path = os.path.join(os.path.dirname(__file__), ct_model_file)
|
106 |
translator = ctranslate2.Translator(ct_model_full_path, device)
|
|
|
|
|
|
|
107 |
|
108 |
+
#model_dict = load_models()
|
109 |
+
|
110 |
+
print('\nDone importing models 🙈\n')
|
111 |
|
112 |
|
113 |
def translate_detect(userinput: str, target_lang: str):
|