Aytaj commited on
Commit
13ee0fc
·
1 Parent(s): 7f68d8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -2,15 +2,11 @@
2
  import streamlit as st
3
  from transformers import pipeline
4
 
5
- st.title("Translate to French")
6
- input_text = st.text_input("Enter text to translate")
 
 
 
 
 
7
 
8
- if st.button("Translate"):
9
- # Specify the translation task explicitly
10
- pipe = pipeline(task="translation", model="facebook/mbart-large-cc25", tokenizer="facebook/mbart-large-cc25")
11
-
12
- # Perform translation
13
- translation = pipe(input_text, target_lang="fr")[0]["translation_text"]
14
-
15
- # Display the translated text
16
- st.write(translation)
 
2
  import streamlit as st
3
  from transformers import pipeline
4
 
5
+ def main():
6
+ st.title("Translate to French")
7
+ sentence = st.text_input("Enter your sentence:")
8
+ if st.button("Translate"):
9
+ pipe = pipeline(model="facebook/m2m100_418M")
10
+ translation = pipe(sentence, target_lang="fr")[0]["translation_text"]
11
+ st.write(translation)
12