Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -110,15 +110,16 @@ def generate_pdf(ids):
|
|
| 110 |
st.title("Traduction d'une phrase en pictogrammes ARASAAC")
|
| 111 |
sentence = st.text_input("Entrez une phrase en français:")
|
| 112 |
if sentence:
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
|
|
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
|
| 120 |
-
|
| 121 |
-
|
| 122 |
|
| 123 |
# Container to hold the download button
|
| 124 |
pdf_path = generate_pdf(pictogram_ids)
|
|
|
|
| 110 |
st.title("Traduction d'une phrase en pictogrammes ARASAAC")
|
| 111 |
sentence = st.text_input("Entrez une phrase en français:")
|
| 112 |
if sentence:
|
| 113 |
+
with st.spinner("Affichage des pictogrammes..."):
|
| 114 |
+
inputs = tokenizer(sentence, return_tensors="pt").input_ids
|
| 115 |
+
outputs = model.generate(inputs, max_new_tokens=40, do_sample=True, top_k=30, top_p=0.95)
|
| 116 |
+
pred = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 117 |
|
| 118 |
+
sentence_to_map = process_output_trad(pred)
|
| 119 |
+
pictogram_ids = [get_id_picto_from_predicted_lemma(lexicon, lemma) for lemma in sentence_to_map]
|
| 120 |
|
| 121 |
+
html = generate_html(pictogram_ids)
|
| 122 |
+
st.components.v1.html(html, height=500, scrolling=True)
|
| 123 |
|
| 124 |
# Container to hold the download button
|
| 125 |
pdf_path = generate_pdf(pictogram_ids)
|