Aytaj commited on
Commit
b65cb69
·
1 Parent(s): afab959

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -1,5 +1,4 @@
1
  # prompt: write a streamlit app that converts english text into french text when translate button is pressed. The title of page should be "Translate to French"."
2
-
3
  import streamlit as st
4
  from transformers import pipeline
5
 
@@ -8,6 +7,11 @@ st.title("Translate to French")
8
  input_text = st.text_input("Enter text to translate")
9
 
10
  if st.button("Translate"):
11
- pipe = pipeline(model="facebook/mbart-large-cc25")
 
 
 
12
  translation = pipe(input_text, target_lang="fr")[0]["translation_text"]
 
 
13
  st.write(translation)
 
1
  # prompt: write a streamlit app that converts english text into french text when translate button is pressed. The title of page should be "Translate to French"."
 
2
  import streamlit as st
3
  from transformers import pipeline
4
 
 
7
  input_text = st.text_input("Enter text to translate")
8
 
9
  if st.button("Translate"):
10
+ # Specify the translation task explicitly
11
+ pipe = pipeline(task="translation", model="facebook/mbart-large-cc25", tokenizer="facebook/mbart-large-cc25")
12
+
13
+ # Perform translation
14
  translation = pipe(input_text, target_lang="fr")[0]["translation_text"]
15
+
16
+ # Display the translated text
17
  st.write(translation)