Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,26 @@
|
|
1 |
-
import
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# Load your Hugging Face model
|
5 |
translator = pipeline("translation_en_to_fr", model="dreyyyy/EN-FR", device=-1) # Use CPU explicitly
|
6 |
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
#
|
9 |
-
|
10 |
-
result = translator(input_text)
|
11 |
-
return result[0]["translation_text"]
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
1 |
+
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# Load your Hugging Face model
|
5 |
translator = pipeline("translation_en_to_fr", model="dreyyyy/EN-FR", device=-1) # Use CPU explicitly
|
6 |
|
7 |
+
# Streamlit app interface
|
8 |
+
st.title("Translation Service")
|
9 |
+
st.subheader("Translate English to French")
|
10 |
+
st.write("This app uses a Hugging Face model to translate English text into French.")
|
11 |
|
12 |
+
# Input text box
|
13 |
+
input_text = st.text_area("Enter English Text:", placeholder="Type your text here...")
|
|
|
|
|
14 |
|
15 |
+
# Translate button
|
16 |
+
if st.button("Translate"):
|
17 |
+
if input_text.strip():
|
18 |
+
# Perform translation
|
19 |
+
result = translator(input_text)
|
20 |
+
translated_text = result[0]["translation_text"]
|
21 |
+
|
22 |
+
# Display the translation
|
23 |
+
st.subheader("Translation in French:")
|
24 |
+
st.write(translated_text)
|
25 |
+
else:
|
26 |
+
st.warning("Please enter some text to translate.")
|