drey1 / app.py
dreyyyy's picture
Update app.py
934c758 verified
raw
history blame
878 Bytes
import streamlit as st
from transformers import pipeline
# Load your Hugging Face model
translator = pipeline("translation_en_to_fr", model="dreyyyy/EN-FR", device=-1) # Use CPU explicitly
# Streamlit app interface
st.title("Translation Service")
st.subheader("Translate English to French")
st.write("This app uses a Hugging Face model to translate English text into French.")
# Input text box
input_text = st.text_area("Enter English Text:", placeholder="Type your text here...")
# Translate button
if st.button("Translate"):
if input_text.strip():
# Perform translation
result = translator(input_text)
translated_text = result[0]["translation_text"]
# Display the translation
st.subheader("Translation in French:")
st.write(translated_text)
else:
st.warning("Please enter some text to translate.")