Spaces:
Sleeping
Sleeping
Commit ยท
0ab3218
1
Parent(s): e988236
add
Browse files- app.py +81 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
def translate_text(text):
|
| 5 |
+
model = pipeline("translation", model='Helsinki-NLP/opus-mt-ko-en')
|
| 6 |
+
result = model(text)
|
| 7 |
+
return result[0]['translation_text']
|
| 8 |
+
|
| 9 |
+
def main():
|
| 10 |
+
# ํ์ด์ง ์ค์
|
| 11 |
+
st.set_page_config(
|
| 12 |
+
page_title="ํ์ ๋ฒ์ญ๊ธฐ",
|
| 13 |
+
page_icon="๐",
|
| 14 |
+
layout="centered"
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
# CSS ์คํ์ผ ์ ์ฉ
|
| 18 |
+
st.markdown("""
|
| 19 |
+
<style>
|
| 20 |
+
.main-header {
|
| 21 |
+
font-size: 2.5rem;
|
| 22 |
+
color: #1E88E5;
|
| 23 |
+
text-align: center;
|
| 24 |
+
padding: 1rem 0;
|
| 25 |
+
font-weight: bold;
|
| 26 |
+
}
|
| 27 |
+
.stButton>button {
|
| 28 |
+
width: 100%;
|
| 29 |
+
background-color: #1E88E5;
|
| 30 |
+
color: white;
|
| 31 |
+
font-size: 1.2rem;
|
| 32 |
+
padding: 0.5rem 0;
|
| 33 |
+
}
|
| 34 |
+
.result-box {
|
| 35 |
+
padding: 1.5rem;
|
| 36 |
+
border-radius: 10px;
|
| 37 |
+
background-color: #f0f2f6;
|
| 38 |
+
margin: 1rem 0;
|
| 39 |
+
}
|
| 40 |
+
</style>
|
| 41 |
+
""", unsafe_allow_html=True)
|
| 42 |
+
|
| 43 |
+
# ํค๋
|
| 44 |
+
st.markdown('<p class="main-header">๐ ํ๊ธ โ ์์ด ๋ฒ์ญ๊ธฐ</p>', unsafe_allow_html=True)
|
| 45 |
+
|
| 46 |
+
# ์ค๋ช
ํ
์คํธ
|
| 47 |
+
st.markdown("#### ํ๊ตญ์ด๋ฅผ ์์ด๋ก ๋ฒ์ญํด๋๋ฆฝ๋๋ค! ์๋์ ๋ฒ์ญํ๊ณ ์ถ์ ํ
์คํธ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์. ๐")
|
| 48 |
+
|
| 49 |
+
# ๊ตฌ๋ถ์
|
| 50 |
+
st.markdown("---")
|
| 51 |
+
|
| 52 |
+
# ์
๋ ฅ ์ปฌ๋ผ๊ณผ ๊ฒฐ๊ณผ ์ปฌ๋ผ ์์ฑ
|
| 53 |
+
col1, col2 = st.columns([1, 1])
|
| 54 |
+
|
| 55 |
+
with col1:
|
| 56 |
+
st.markdown("### ํ๊ตญ์ด ์
๋ ฅ")
|
| 57 |
+
user_input = st.text_area("", height=200, placeholder="๋ฒ์ญํ ํ๊ธ์ ์
๋ ฅํ์ธ์...")
|
| 58 |
+
|
| 59 |
+
with col2:
|
| 60 |
+
st.markdown("### ์์ด ๋ฒ์ญ")
|
| 61 |
+
if user_input:
|
| 62 |
+
translation = translate_text(user_input)
|
| 63 |
+
st.markdown('<div class="result-box">' + translation + '</div>', unsafe_allow_html=True)
|
| 64 |
+
else:
|
| 65 |
+
st.markdown('<div class="result-box">๋ฒ์ญ ๊ฒฐ๊ณผ๊ฐ ์ฌ๊ธฐ์ ํ์๋ฉ๋๋ค.</div>', unsafe_allow_html=True)
|
| 66 |
+
|
| 67 |
+
# ๋ฒ์ญ ๋ฒํผ
|
| 68 |
+
if st.button('๋ฒ์ญํ๊ธฐ ๐'):
|
| 69 |
+
if user_input:
|
| 70 |
+
translation = translate_text(user_input)
|
| 71 |
+
st.success('๋ฒ์ญ์ด ์๋ฃ๋์์ต๋๋ค! โจ')
|
| 72 |
+
else:
|
| 73 |
+
st.warning('โ ๏ธ ํ
์คํธ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.')
|
| 74 |
+
|
| 75 |
+
# ํธํฐ
|
| 76 |
+
st.markdown("---")
|
| 77 |
+
st.markdown("##### Made with โค๏ธ using Streamlit")
|
| 78 |
+
|
| 79 |
+
if __name__ == '__main__':
|
| 80 |
+
main()
|
| 81 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
transformers
|