Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -112,18 +112,17 @@ st.info("Text-to-Pictograms traduit une phrase en français en pictogrammes ARAS
|
|
112 |
|
113 |
sentence = st.text_input("Entrez une phrase en français:")
|
114 |
with st.spinner("Affichage des pictogrammes..."):
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
pred = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
119 |
|
120 |
-
|
121 |
-
|
122 |
|
123 |
-
|
124 |
-
|
125 |
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
112 |
|
113 |
sentence = st.text_input("Entrez une phrase en français:")
|
114 |
with st.spinner("Affichage des pictogrammes..."):
|
115 |
+
inputs = tokenizer(sentence, return_tensors="pt").input_ids
|
116 |
+
outputs = model.generate(inputs, max_new_tokens=40, do_sample=True, top_k=30, top_p=0.95)
|
117 |
+
pred = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
118 |
|
119 |
+
sentence_to_map = process_output_trad(pred)
|
120 |
+
pictogram_ids = [get_id_picto_from_predicted_lemma(lexicon, lemma) for lemma in sentence_to_map]
|
121 |
|
122 |
+
html = generate_html(pictogram_ids)
|
123 |
+
st.components.v1.html(html, height=500, scrolling=True)
|
124 |
|
125 |
+
# Container to hold the download button
|
126 |
+
pdf_path = generate_pdf(pictogram_ids)
|
127 |
+
with open(pdf_path, "rb") as pdf_file:
|
128 |
+
st.download_button(label="Télécharger la traduction en PDF", data=pdf_file, file_name="pictograms.pdf", mime="application/pdf")
|