blockenters commited on
Commit
0ab3218
ยท
1 Parent(s): e988236
Files changed (2) hide show
  1. app.py +81 -0
  2. 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