cecilemacaire commited on
Commit
0663dbe
·
verified ·
1 Parent(s): 3d448f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
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
- if st.button('Valider'):
116
- inputs = tokenizer(sentence, return_tensors="pt").input_ids
117
- outputs = model.generate(inputs, max_new_tokens=40, do_sample=True, top_k=30, top_p=0.95)
118
- pred = tokenizer.decode(outputs[0], skip_special_tokens=True)
119
 
120
- sentence_to_map = process_output_trad(pred)
121
- pictogram_ids = [get_id_picto_from_predicted_lemma(lexicon, lemma) for lemma in sentence_to_map]
122
 
123
- html = generate_html(pictogram_ids)
124
- st.components.v1.html(html, height=500, scrolling=True)
125
 
126
- # Container to hold the download button
127
- pdf_path = generate_pdf(pictogram_ids)
128
- with open(pdf_path, "rb") as pdf_file:
129
- st.download_button(label="Télécharger la traduction en PDF", data=pdf_file, file_name="pictograms.pdf", mime="application/pdf")
 
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")