Commit
•
9479474
1
Parent(s):
bc744b9
Update modelisation_seq2seq_tab.py
Browse files- tabs/modelisation_seq2seq_tab.py +18 -18
tabs/modelisation_seq2seq_tab.py
CHANGED
@@ -89,12 +89,11 @@ def display_translation(n1, Lang,model_type):
|
|
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(
|
93 |
-
print("->"+
|
94 |
-
return requests.get(url
|
95 |
-
|
96 |
-
|
97 |
-
def display_translation(n1, Lang,model_type):
|
98 |
global df_data_src, df_data_tgt, placeholder
|
99 |
|
100 |
placeholder = st.empty()
|
@@ -105,24 +104,25 @@ def display_translation(n1, Lang,model_type):
|
|
105 |
source = Lang[:2]
|
106 |
target = Lang[-2:]
|
107 |
params = []
|
108 |
-
if model_type==1:
|
109 |
-
|
110 |
-
url = "https://demosthene-or-api-avr23-cds-translation.hf.space/small_vocab/rnn"
|
111 |
else:
|
112 |
-
|
113 |
-
url = "https://demosthene-or-api-avr23-cds-translation.hf.space/small_vocab/transformer"
|
114 |
for i in range(3):
|
115 |
-
#
|
116 |
-
|
|
|
117 |
|
118 |
with Pool(3) as p:
|
|
|
119 |
responses = p.map(fetch_translation, params)
|
120 |
|
121 |
-
for
|
122 |
-
|
123 |
-
|
124 |
-
st.write("**
|
125 |
-
st.write("**
|
|
|
126 |
st.write("")
|
127 |
with placeholder:
|
128 |
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>", \
|
|
|
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 |
+
print("->"+url)
|
94 |
+
return requests.get(url)
|
95 |
+
|
96 |
+
def display_translation(n1, Lang, model_type):
|
|
|
97 |
global df_data_src, df_data_tgt, placeholder
|
98 |
|
99 |
placeholder = st.empty()
|
|
|
104 |
source = Lang[:2]
|
105 |
target = Lang[-2:]
|
106 |
params = []
|
107 |
+
if model_type == 1:
|
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 |
|
120 |
+
for response, s_text in zip(responses, s):
|
121 |
+
# Récupération des résultats
|
122 |
+
s_trad.append(response.json())
|
123 |
+
st.write(f"**{source} :** :blue[{s_text}]")
|
124 |
+
st.write(f"**{target} :** {s_trad[-1]}")
|
125 |
+
st.write(f"**ref. :** {s_trad_ref[i]}")
|
126 |
st.write("")
|
127 |
with placeholder:
|
128 |
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>", \
|