Spaces:
Running
Running
Upload 2 files
Browse files- app.py +37 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
|
5 |
+
translator = pipeline("translation", model="sarahai/nllb-uzbek-cyrillic-to-russian")
|
6 |
+
summarizer = pipeline("summarization", model="sarahai/ruT5-base-summarizer", max_length=512, truncation=True)
|
7 |
+
|
8 |
+
def translate_and_summarize(uzbek_text):
|
9 |
+
"""Translates Uzbek text to Russian and summarizes the translation."""
|
10 |
+
|
11 |
+
|
12 |
+
if not uzbek_text:
|
13 |
+
st.warning("Пожалуйста введите текст для перевода")
|
14 |
+
return
|
15 |
+
|
16 |
+
try:
|
17 |
+
|
18 |
+
russian_text = translator(uzbek_text)[0]["translation_text"]
|
19 |
+
|
20 |
+
|
21 |
+
summary = summarizer(russian_text, max_length=200, truncation=True)[0]["summary_text"]
|
22 |
+
|
23 |
+
|
24 |
+
st.success("Перевод:")
|
25 |
+
st.write(russian_text)
|
26 |
+
st.success("Краткое содержание:")
|
27 |
+
st.write(summary)
|
28 |
+
except Exception as e:
|
29 |
+
st.error(f"Произошла ошибка: {e}")
|
30 |
+
|
31 |
+
st.title("Перевод узбекских текстов и суммаризация русских")
|
32 |
+
st.subheader("Переведите текст с узбекского на русский язык и кратко его суммируйте с помощью моделей Hugging Face.")
|
33 |
+
|
34 |
+
uzbek_text = st.text_area("Enter Uzbek Text", height=200)
|
35 |
+
|
36 |
+
if st.button("Перевод и суммаризация "):
|
37 |
+
translate_and_summarize(uzbek_text)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
transformers
|