Demosthene-OR commited on
Commit
6f7f387
1 Parent(s): fbf82bf

Update modelisation_seq2seq_tab.py

Browse files
Files changed (1) hide show
  1. tabs/modelisation_seq2seq_tab.py +25 -22
tabs/modelisation_seq2seq_tab.py CHANGED
@@ -58,8 +58,8 @@ def load_all_data():
58
  n1 = 0
59
  df_data_en, df_data_fr, translation_en_fr, translation_fr_en, lang_classifier, model_speech, finetuned_translation_en_fr = load_all_data()
60
 
61
- '''
62
- def display_translation(n1, Lang,model_type):
63
  global df_data_src, df_data_tgt, placeholder
64
 
65
  placeholder = st.empty()
@@ -88,11 +88,11 @@ def display_translation(n1, Lang,model_type):
88
  with placeholder:
89
  st.write("<p style='text-align:center;background-color:red; color:white')>Score Bleu = "+str(int(round(corpus_bleu(s_trad,[s_trad_ref]).score,0)))+"%</p>", \
90
  unsafe_allow_html=True)
91
- '''
92
- def fetch_translation(url):
93
  return requests.get(url)
94
 
95
- def display_translation(n1, Lang, model_type):
96
  global df_data_src, df_data_tgt, placeholder
97
 
98
  n = 3
@@ -135,13 +135,13 @@ def display_translation(n1, Lang, model_type):
135
  unsafe_allow_html=True)
136
 
137
 
138
- '''
139
- async def fetch_translation(url, params):
140
  async with aiohttp.ClientSession() as session:
141
  async with session.get(url, params=params) as response:
142
  return await response.json()
143
 
144
- async def display_translation(n1, Lang, model_type):
145
  global df_data_src, df_data_tgt, placeholder
146
 
147
  placeholder = st.empty()
@@ -177,7 +177,6 @@ async def display_translation(n1, Lang, model_type):
177
  with placeholder:
178
  st.write("<p style='text-align:center;background-color:red; color:white')>Score Bleu = "+str(int(round(corpus_bleu(s_trad,[s_trad_ref]).score,0)))+"%</p>", \
179
  unsafe_allow_html=True)
180
- '''
181
 
182
 
183
  @st.cache_data
@@ -274,19 +273,23 @@ def run():
274
 
275
  st.write("## **"+tr("Résultats")+" :**\n")
276
  if (chosen_id == "tab1"):
277
- t0 = time.time()
278
- # Exécuter la fonction asynchrone
279
- # asyncio.run(display_translation(n1, Lang, 1))
280
- display_translation(n1, Lang,1)
281
- t1 = time.time()
282
- st.write("Durée: "+str(t1-t0))
283
- else:
284
- t0 = time.time()
285
- # Exécuter la fonction asynchrone
286
- # asyncio.run(display_translation(n1, Lang, 2))
287
- display_translation(n1, Lang,2)
288
- t1 = time.time()
289
- st.write("Durée: "+str(t1-t0))
 
 
 
 
290
 
291
  st.write("## **"+tr("Details sur la méthode")+" :**\n")
292
  if (chosen_id == "tab1"):
 
58
  n1 = 0
59
  df_data_en, df_data_fr, translation_en_fr, translation_fr_en, lang_classifier, model_speech, finetuned_translation_en_fr = load_all_data()
60
 
61
+
62
+ def display_translation3(n1, Lang,model_type):
63
  global df_data_src, df_data_tgt, placeholder
64
 
65
  placeholder = st.empty()
 
88
  with placeholder:
89
  st.write("<p style='text-align:center;background-color:red; color:white')>Score Bleu = "+str(int(round(corpus_bleu(s_trad,[s_trad_ref]).score,0)))+"%</p>", \
90
  unsafe_allow_html=True)
91
+
92
+ def fetch_translation2(url):
93
  return requests.get(url)
94
 
95
+ def display_translation2(n1, Lang, model_type):
96
  global df_data_src, df_data_tgt, placeholder
97
 
98
  n = 3
 
135
  unsafe_allow_html=True)
136
 
137
 
138
+
139
+ async def fetch_translation1(url, params):
140
  async with aiohttp.ClientSession() as session:
141
  async with session.get(url, params=params) as response:
142
  return await response.json()
143
 
144
+ async def display_translation1(n1, Lang, model_type):
145
  global df_data_src, df_data_tgt, placeholder
146
 
147
  placeholder = st.empty()
 
177
  with placeholder:
178
  st.write("<p style='text-align:center;background-color:red; color:white')>Score Bleu = "+str(int(round(corpus_bleu(s_trad,[s_trad_ref]).score,0)))+"%</p>", \
179
  unsafe_allow_html=True)
 
180
 
181
 
182
  @st.cache_data
 
273
 
274
  st.write("## **"+tr("Résultats")+" :**\n")
275
  if (chosen_id == "tab1"):
276
+ mode = 1 # RNN
277
+ else:
278
+ mode = 2 # Transformer
279
+
280
+ # Exécuter la fonction asynchrone
281
+ t0 = time.time()
282
+ asyncio.run(display_translation1(n1, Lang, mode))
283
+ t1 = time.time()
284
+ st.write("Durée 1: "+str(t1-t0))
285
+ t0 = time.time()
286
+ display_translation2(n1, Lang,mode)
287
+ t1 = time.time()
288
+ st.write("Durée 2: "+str(t1-t0))
289
+ t0 = time.time()
290
+ display_translation3(n1, Lang,mode)
291
+ t1 = time.time()
292
+ st.write("Durée 3: "+str(t1-t0))
293
 
294
  st.write("## **"+tr("Details sur la méthode")+" :**\n")
295
  if (chosen_id == "tab1"):