Demosthene-OR
commited on
Commit
•
daea820
1
Parent(s):
6b65ad0
Update main_dl.py
Browse files- main_dl.py +9 -5
main_dl.py
CHANGED
@@ -45,8 +45,6 @@ def load_vocab(file_path):
|
|
45 |
def decode_sequence_rnn(input_sentence, src, tgt):
|
46 |
global translation_model
|
47 |
|
48 |
-
if translation_model not in globals():
|
49 |
-
load_rnn()
|
50 |
vocab_size = 15000
|
51 |
sequence_length = 50
|
52 |
|
@@ -184,8 +182,6 @@ class PositionalEmbedding(layers.Layer):
|
|
184 |
def decode_sequence_transf(input_sentence, src, tgt):
|
185 |
global translation_model
|
186 |
|
187 |
-
if translation_model not in globals():
|
188 |
-
load_transformer()
|
189 |
vocab_size = 15000
|
190 |
sequence_length = 30
|
191 |
|
@@ -288,7 +284,7 @@ init_dl_identifier()
|
|
288 |
def lang_id_dl(sentences):
|
289 |
global dl_model, label_encoder, lan_to_language
|
290 |
|
291 |
-
if dl_model not in globals():
|
292 |
init_dl_identifier()
|
293 |
if "str" in str(type(sentences)): predictions = dl_model.predict(encode_text([sentences]))
|
294 |
else: predictions = dl_model.predict(encode_text(sentences))
|
@@ -312,6 +308,10 @@ async def trad_rnn(lang_tgt:str,
|
|
312 |
texte: str):
|
313 |
global translation_model
|
314 |
|
|
|
|
|
|
|
|
|
315 |
if (lang_tgt=='en'):
|
316 |
translation_model = rnn_fr_en
|
317 |
return decode_sequence_rnn(texte, "fr", "en")
|
@@ -324,6 +324,10 @@ async def trad_transformer(lang_tgt:str,
|
|
324 |
texte: str):
|
325 |
global translation_model
|
326 |
|
|
|
|
|
|
|
|
|
327 |
if (lang_tgt=='en'):
|
328 |
translation_model = transformer_fr_en
|
329 |
return decode_sequence_transf(texte, "fr", "en")
|
|
|
45 |
def decode_sequence_rnn(input_sentence, src, tgt):
|
46 |
global translation_model
|
47 |
|
|
|
|
|
48 |
vocab_size = 15000
|
49 |
sequence_length = 50
|
50 |
|
|
|
182 |
def decode_sequence_transf(input_sentence, src, tgt):
|
183 |
global translation_model
|
184 |
|
|
|
|
|
185 |
vocab_size = 15000
|
186 |
sequence_length = 30
|
187 |
|
|
|
284 |
def lang_id_dl(sentences):
|
285 |
global dl_model, label_encoder, lan_to_language
|
286 |
|
287 |
+
if 'dl_model' not in globals():
|
288 |
init_dl_identifier()
|
289 |
if "str" in str(type(sentences)): predictions = dl_model.predict(encode_text([sentences]))
|
290 |
else: predictions = dl_model.predict(encode_text(sentences))
|
|
|
308 |
texte: str):
|
309 |
global translation_model
|
310 |
|
311 |
+
if 'translation_model' not in globals():
|
312 |
+
load_rnn()
|
313 |
+
load_transformer()
|
314 |
+
|
315 |
if (lang_tgt=='en'):
|
316 |
translation_model = rnn_fr_en
|
317 |
return decode_sequence_rnn(texte, "fr", "en")
|
|
|
324 |
texte: str):
|
325 |
global translation_model
|
326 |
|
327 |
+
if 'translation_model' not in globals():
|
328 |
+
load_rnn()
|
329 |
+
load_transformer()
|
330 |
+
|
331 |
if (lang_tgt=='en'):
|
332 |
translation_model = transformer_fr_en
|
333 |
return decode_sequence_transf(texte, "fr", "en")
|