Spaces:
Sleeping
Sleeping
Download app.py from KateProxa/streamlit_app: direct link, hf CLI and curl.
- Browser
- Download file 901 Bytes
-
https://huggingface.co/spaces/KateProxa/streamlit_app/resolve/main/app.py
- Command line
-
hf download hf://spaces/KateProxa/streamlit_app/app.py
-
curl -L -o app.py https://huggingface.co/spaces/KateProxa/streamlit_app/resolve/main/app.py
901 Bytes
| import io | |
| import streamlit as st | |
| from transformers import pipeline | |
| #@st.cache_data | |
| # загружаю модель | |
| def load_model(): | |
| return pipeline("translation_ru_to_fr", model = "Helsinki-NLP/opus-mt-ru-fr") | |
| translation = load_model() | |
| # Вывожу заголовок страницы средствами Streamlit | |
| st.title('Translator from Russian to French') | |
| st.write('Это приложение для перевода текста с русского языка на французский') | |
| text = st.text_area('Введите текст для перевода', 'Скоро наступит Новый Год!') | |
| # Кнопка для запуска | |
| result = st.button('Перевести') | |
| # Если кнопка нажата, то запускаем | |
| if result: | |
| tr_text = translation(text) | |
| st.write("Перевод:", tr_text[0]['translation_text']) |