Spaces:
Configuration error
Configuration error
Delete app.py
Browse files
app.py
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from transformers import pipeline
|
3 |
-
import nltk
|
4 |
-
nltk.download('punkt')
|
5 |
-
from nltk.tokenize import sent_tokenize
|
6 |
-
|
7 |
-
# Load pipeline for translation
|
8 |
-
st.set_page_config(page_title="English to Vietnamese Translator", page_icon="🌐", layout="wide")
|
9 |
-
st.title("🌐 English to Vietnamese Translator")
|
10 |
-
|
11 |
-
model_checkpoint = "hHoai/hoaih"
|
12 |
-
translator = pipeline("translation", model=model_checkpoint)
|
13 |
-
|
14 |
-
# Create two columns for input and output
|
15 |
-
col1, col2 = st.columns(2)
|
16 |
-
|
17 |
-
# Add CSS for styling
|
18 |
-
st.markdown("""
|
19 |
-
<style>
|
20 |
-
.reportview-container {
|
21 |
-
flex-direction: row;
|
22 |
-
justify-content: center;
|
23 |
-
align-items: center;
|
24 |
-
}
|
25 |
-
.sidebar .sidebar-content {
|
26 |
-
background-image: linear-gradient(#2e7bcf, #2e7bcf);
|
27 |
-
color: white;
|
28 |
-
}
|
29 |
-
.css-1d391kg {
|
30 |
-
font-size: 20px;
|
31 |
-
}
|
32 |
-
.css-1aumxhk {
|
33 |
-
background-color: #f0f2f6;
|
34 |
-
padding: 20px;
|
35 |
-
border-radius: 10px;
|
36 |
-
}
|
37 |
-
.css-1aumxhk:hover {
|
38 |
-
background-color: #e8e9eb;
|
39 |
-
}
|
40 |
-
.css-1aumxhk:focus {
|
41 |
-
outline: none;
|
42 |
-
border: 2px solid #2e7bcf;
|
43 |
-
}
|
44 |
-
.css-12oz5g7 {
|
45 |
-
font-size: 24px;
|
46 |
-
font-weight: bold;
|
47 |
-
}
|
48 |
-
</style>
|
49 |
-
""", unsafe_allow_html=True)
|
50 |
-
|
51 |
-
with col1:
|
52 |
-
st.header("Input")
|
53 |
-
input_text = st.text_area("Enter English text here maximum 2 line:", height=300, placeholder="Type your text here...")
|
54 |
-
|
55 |
-
with col2:
|
56 |
-
st.header("Output")
|
57 |
-
if input_text:
|
58 |
-
sentences = sent_tokenize(input_text)
|
59 |
-
translation_text = ""
|
60 |
-
for sentence in sentences:
|
61 |
-
translation = translator(sentence)
|
62 |
-
translation_text += translation[0]["translation_text"] + " "
|
63 |
-
st.text_area("Translated text will appear here:", value=translation_text.strip(), height=300, disabled=True)
|
64 |
-
else:
|
65 |
-
st.text_area("Translated text will appear here:", value="", height=300, disabled=True)
|
66 |
-
|
67 |
-
# Add footer
|
68 |
-
st.markdown("""
|
69 |
-
<div style="text-align: center; margin-top: 50px;">
|
70 |
-
<p>Developed with ❤️ by [hHoai]</p>
|
71 |
-
</div>
|
72 |
-
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|