Demosthene-OR commited on
Commit
b009916
1 Parent(s): cfeeb53

Update modelisation_seq2seq_tab.py

Browse files
Files changed (1) hide show
  1. tabs/modelisation_seq2seq_tab.py +5 -4
tabs/modelisation_seq2seq_tab.py CHANGED
@@ -96,11 +96,12 @@ def fetch_translation(url):
96
  def display_translation(n1, Lang, model_type):
97
  global df_data_src, df_data_tgt, placeholder
98
 
 
99
  placeholder = st.empty()
100
  with st.status(":sunglasses:", expanded=True):
101
- s = df_data_src.iloc[n1:n1+3][0].tolist()
102
  s_trad = []
103
- s_trad_ref = df_data_tgt.iloc[n1:n1+3][0].tolist()
104
  source = Lang[:2]
105
  target = Lang[-2:]
106
  params = []
@@ -108,12 +109,12 @@ def display_translation(n1, Lang, model_type):
108
  url_base = "https://demosthene-or-api-avr23-cds-translation.hf.space/small_vocab/rnn"
109
  else:
110
  url_base = "https://demosthene-or-api-avr23-cds-translation.hf.space/small_vocab/transformer"
111
- for i in range(3):
112
  # Construction de l'URL avec les paramètres
113
  url = f"{url_base}?lang_tgt={target}&texte={s[i]}"
114
  params.append(url)
115
 
116
- with Pool(3) as p:
117
  # Appels parallèles à fetch_translation avec les URLs
118
  responses = p.map(fetch_translation, params)
119
 
 
96
  def display_translation(n1, Lang, model_type):
97
  global df_data_src, df_data_tgt, placeholder
98
 
99
+ n = 3
100
  placeholder = st.empty()
101
  with st.status(":sunglasses:", expanded=True):
102
+ s = df_data_src.iloc[n1:n1+n][0].tolist()
103
  s_trad = []
104
+ s_trad_ref = df_data_tgt.iloc[n1:n1+n][0].tolist()
105
  source = Lang[:2]
106
  target = Lang[-2:]
107
  params = []
 
109
  url_base = "https://demosthene-or-api-avr23-cds-translation.hf.space/small_vocab/rnn"
110
  else:
111
  url_base = "https://demosthene-or-api-avr23-cds-translation.hf.space/small_vocab/transformer"
112
+ for i in range(n):
113
  # Construction de l'URL avec les paramètres
114
  url = f"{url_base}?lang_tgt={target}&texte={s[i]}"
115
  params.append(url)
116
 
117
+ with Pool(n) as p:
118
  # Appels parallèles à fetch_translation avec les URLs
119
  responses = p.map(fetch_translation, params)
120