Download app.py from AlexVed/TestApp: direct link, hf CLI and curl.
- Browser
- Download file 531 Bytes
-
https://huggingface.co/spaces/AlexVed/TestApp/resolve/main/app.py
- Command line
-
hf download hf://spaces/AlexVed/TestApp/app.py
-
curl -L -o app.py https://huggingface.co/spaces/AlexVed/TestApp/resolve/main/app.py
531 Bytes
| import streamlit as st | |
| from transformers import pipeline | |
| # Load the translation model | |
| translator = pipeline('translation_en_to_uk', model='Helsinki-NLP/opus-mt-en-uk') | |
| # Streamlit UI | |
| st.title("English to Ukrainian Translator") | |
| text = st.text_area("Enter English text:") | |
| if st.button("Translate"): | |
| if text: | |
| translated_text = translator(text, max_length=100)[0]['translation_text'] | |
| st.subheader("Translation:") | |
| st.write(translated_text) | |
| else: | |
| st.warning("Please enter text to translate.") | |