Update app.py
Browse files
app.py
CHANGED
@@ -108,40 +108,95 @@ def process_model(target_word):
|
|
108 |
return fig, similar_words_text, dissimilar_words_text
|
109 |
|
110 |
|
111 |
-
|
112 |
# Gradio ์ธํฐํ์ด์ค ์์
|
113 |
-
with gr.Blocks(css="
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
with gr.Row():
|
118 |
# ์ฌ์ฉ์ ์
๋ ฅ ๋ฐ์ค๋ฅผ ๊ฐ์กฐํ๊ธฐ ์ํด ์คํ์ผ์ ๋ณ๊ฒฝ
|
119 |
with gr.Column():
|
120 |
-
word_input = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
121 |
submit_btn = gr.Button("์ ์ถ", elem_id="submit-btn")
|
122 |
-
bulletin = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
with gr.Row():
|
125 |
# ์๊ฐํ ํ๋ฉด์ ํฌ๊ธฐ๋ฅผ CSS๋ก ์ฆ๊ฐ
|
126 |
plot_output = gr.Plot(label="Word Embedding 3D ์๊ฐํ", elem_id="plot-box")
|
127 |
|
128 |
with gr.Column(scale=0.3): # ์ปฌ๋ผ์ ๋๋น๋ฅผ ์ค์ด๊ธฐ ์ํด scale ๊ฐ์ ๋ฎ์ถค
|
129 |
-
similar_words_output = gr.Textbox(
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
submit_btn.click(
|
134 |
fn=process_text,
|
135 |
-
# word_input = word_input.lower(),
|
136 |
inputs=[word_input],
|
137 |
-
outputs=[plot_output, similar_words_output, dissimilar_words_output]
|
138 |
-
|
139 |
-
)
|
140 |
|
141 |
-
# "Enter" ํค ์
๋ ฅ ์ ๋์ ์ค์
|
142 |
word_input.submit(
|
143 |
fn=process_text,
|
144 |
-
# word_input = word_input.lower(),
|
145 |
inputs=[word_input],
|
146 |
outputs=[plot_output, similar_words_output, dissimilar_words_output],
|
147 |
preprocess=lambda word: word.lower() if word else "" # None ์ฒดํฌ ํ ์๋ฌธ์ ๋ณํ
|
|
|
108 |
return fig, similar_words_text, dissimilar_words_text
|
109 |
|
110 |
|
|
|
111 |
# Gradio ์ธํฐํ์ด์ค ์์
|
112 |
+
with gr.Blocks(css="""
|
113 |
+
#input-box {
|
114 |
+
background-color: #ffeef3; /* ์ฐํ ํ์คํ
ํํฌ */
|
115 |
+
border: 2px solid #ffccd5; /* ์ฐํ ํํฌ ํ
๋๋ฆฌ */
|
116 |
+
color: #000; /* ํ
์คํธ ์์ */
|
117 |
+
border-radius: 8px; /* ๋ฅ๊ทผ ํ
๋๋ฆฌ */
|
118 |
+
}
|
119 |
+
#submit-btn {
|
120 |
+
background-color: #ebfbea; /* ์ฐํ ํ์คํ
์ฐ๋์ */
|
121 |
+
border: 2px solid #d6f5d6; /* ์ฐํ ์ฐ๋์ ํ
๋๋ฆฌ */
|
122 |
+
color: #000; /* ํ
์คํธ ์์ */
|
123 |
+
border-radius: 8px; /* ๋ฅ๊ทผ ํ
๋๋ฆฌ */
|
124 |
+
}
|
125 |
+
#bulletin {
|
126 |
+
background-color: #eaf9ff; /* ์ฐํ ํ์คํ
ํ๋์ */
|
127 |
+
border: 2px solid #d3f0f7; /* ์ฐํ ํ๋์ ํ
๋๋ฆฌ */
|
128 |
+
color: #000; /* ํ
์คํธ ์์ */
|
129 |
+
border-radius: 8px; /* ๋ฅ๊ทผ ํ
๋๋ฆฌ */
|
130 |
+
}
|
131 |
+
#similar-words {
|
132 |
+
background-color: #fff0e6; /* ์ฐํ ํ์คํ
์ฃผํฉ์ */
|
133 |
+
border: 2px solid #ffe3cc; /* ์ฐํ ์ฃผํฉ ํ
๋๋ฆฌ */
|
134 |
+
color: #000; /* ํ
์คํธ ์์ */
|
135 |
+
border-radius: 8px; /* ๋ฅ๊ทผ ํ
๋๋ฆฌ */
|
136 |
+
}
|
137 |
+
#dissimilar-words {
|
138 |
+
background-color: #f2e6ff; /* ์ฐํ ํ์คํ
๋ณด๋ผ์ */
|
139 |
+
border: 2px solid #e0ccff; /* ์ฐํ ๋ณด๋ผ ํ
๋๋ฆฌ */
|
140 |
+
color: #000; /* ํ
์คํธ ์์ */
|
141 |
+
border-radius: 8px; /* ๋ฅ๊ทผ ํ
๋๋ฆฌ */
|
142 |
+
}
|
143 |
+
label {
|
144 |
+
font-weight: bold; /* ์ ๋ชฉ ๋ณผ๋์ฒด */
|
145 |
+
}
|
146 |
+
""") as iface:
|
147 |
+
gr.Markdown("# <Inside Out 2> ๋จ์ด ์๋ฏธ ์ง๋ 3D ์๊ฐํ")
|
148 |
+
# gr.Markdown("<Inside Out 2> ๋จ์ด ์๋ฏธ ์ง๋(์๋ฒ ๋ฉ ๋ฒกํฐ) 3D ์๊ฐํ ๋๊ตฌ")
|
149 |
|
150 |
with gr.Row():
|
151 |
# ์ฌ์ฉ์ ์
๋ ฅ ๋ฐ์ค๋ฅผ ๊ฐ์กฐํ๊ธฐ ์ํด ์คํ์ผ์ ๋ณ๊ฒฝ
|
152 |
with gr.Column():
|
153 |
+
word_input = gr.Textbox(
|
154 |
+
label="**๋จ์ด ์
๋ ฅ**",
|
155 |
+
elem_id="input-box",
|
156 |
+
placeholder="ex. emotion, puberty, hockey, friend, anxiety, memory, ...",
|
157 |
+
lines=1
|
158 |
+
)
|
159 |
submit_btn = gr.Button("์ ์ถ", elem_id="submit-btn")
|
160 |
+
bulletin = gr.Textbox(
|
161 |
+
label="์ฌ์ฉ๋ฒ ์๋ด",
|
162 |
+
interactive=False,
|
163 |
+
lines=4,
|
164 |
+
value=(
|
165 |
+
"1. ์์ค์ ๋์จ ๋จ์ด๋ฅผ ์
๋ ฅํ๊ณ [์ ์ถ]์ด๋ [Enter]๋ฅผ ๋๋ฅด์ธ์\n"
|
166 |
+
"2. ์
๋ ฅ ๋จ์ด๋ ๋นจ๊ฐ์, ๊ฐ๊น์ด ๋จ์ด๋ค์ ์ฃผํฉ์, ๋จผ ๋จ์ด๋ค์ ๋ณด๋ผ์์ผ๋ก ๊ฐ์กฐ๋ฉ๋๋ค.\n"
|
167 |
+
"3. <Error>๊ฐ ๋ํ๋๋ ๊ฒฝ์ฐ, ๋ค๋ฅธ ๋จ์ด๋ฅผ ์
๋ ฅํด๋ณด์ธ์.\n"
|
168 |
+
"4. ๋ง์ฐ์ค ๋๋๊ทธ ๋ฐ ์คํฌ๋กค์ ํ์ฉํ์ฌ 3D ํ๋ฉด์ ์ดํด๋ณด์ธ์.\n"
|
169 |
+
"5. ๋จ์ด ์
๋ ฅ์ฐฝ์ ๋ค๋ฅธ ๋จ์ด๋ค๋ ์
๋ ฅํด๋ณด์ธ์."
|
170 |
+
),
|
171 |
+
elem_id="bulletin"
|
172 |
+
)
|
173 |
|
174 |
with gr.Row():
|
175 |
# ์๊ฐํ ํ๋ฉด์ ํฌ๊ธฐ๋ฅผ CSS๋ก ์ฆ๊ฐ
|
176 |
plot_output = gr.Plot(label="Word Embedding 3D ์๊ฐํ", elem_id="plot-box")
|
177 |
|
178 |
with gr.Column(scale=0.3): # ์ปฌ๋ผ์ ๋๋น๋ฅผ ์ค์ด๊ธฐ ์ํด scale ๊ฐ์ ๋ฎ์ถค
|
179 |
+
similar_words_output = gr.Textbox(
|
180 |
+
label="๊ฐ์ฅ ๊ฐ๊น์ด ๋จ์ด 10๊ฐ",
|
181 |
+
interactive=False,
|
182 |
+
lines=5,
|
183 |
+
elem_id="similar-words"
|
184 |
+
)
|
185 |
+
dissimilar_words_output = gr.Textbox(
|
186 |
+
label="๊ฐ์ฅ ๋จผ ๋จ์ด 10๊ฐ",
|
187 |
+
interactive=False,
|
188 |
+
lines=5,
|
189 |
+
elem_id="dissimilar-words"
|
190 |
+
)
|
191 |
|
192 |
submit_btn.click(
|
193 |
fn=process_text,
|
|
|
194 |
inputs=[word_input],
|
195 |
+
outputs=[plot_output, similar_words_output, dissimilar_words_output]
|
196 |
+
)
|
|
|
197 |
|
|
|
198 |
word_input.submit(
|
199 |
fn=process_text,
|
|
|
200 |
inputs=[word_input],
|
201 |
outputs=[plot_output, similar_words_output, dissimilar_words_output],
|
202 |
preprocess=lambda word: word.lower() if word else "" # None ์ฒดํฌ ํ ์๋ฌธ์ ๋ณํ
|