mdj1412 commited on
Commit
641f6f7
โ€ข
1 Parent(s): f6c0686

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -37
app.py CHANGED
@@ -165,8 +165,7 @@ demo = gr.Interface(builder, inputs=[gr.inputs.Dropdown(['Default', 'Eng', 'Kor'
165
  # outputs='label',
166
  title=title, description=description, examples=examples)
167
 
168
- def fn2(a, b):
169
- return [None, None, None]
170
 
171
  with gr.Blocks() as demo1:
172
  gr.Markdown(
@@ -178,51 +177,27 @@ with gr.Blocks() as demo1:
178
 
179
  gr.Markdown(
180
  """
181
- ํ•ด๋‹น ์‚ฌ์ดํŠธ์—์„œ๋Š” ์˜ํ™” ๋ฆฌ๋ทฐ๋ฅผ ์ž…๋ ฅํ–ˆ์„ ๋•Œ, ๊ธ์ •์ ์ธ ๋ฆฌ๋ทฐ์ธ์ง€ ๋ถ€์ •์ ์ธ ๋ฆฌ๋ทฐ์ธ์ง€ ํŒ๋ณ„ ํ•ด์ค€๋‹ค.
 
 
 
182
  """)
183
 
184
-
185
- with gr.Row():
186
- gr.Markdown(
187
- """
188
- ### ์ž…๋ ฅ(Lang, Text)์— ๋Œ€ํ•œ ์„ค๋ช…
189
- ๊ฐ€์šด๋ฐ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์™ผ์ชฝ์— ์žˆ๋Š” ์นธ๋“ค์€ ์ž…๋ ฅ์— ํ•ด๋‹นํ•œ๋‹ค.
190
- * โ€˜Langโ€™์€ ์ž์‹ ์ด ์ž…๋ ฅํ•  ์–ธ์–ด๋ฅผ ์„ ํƒํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ๊ธฐ์ž…์ด ์—†์„ ๊ฒฝ์šฐ(Default)์—๋Š” ํ•œ๊ตญ์–ด์ธ์ง€ ์˜์–ด์ธ์ง€ ์˜ค๋ฅธ์ชฝ ๋ฐ•์Šค โ€˜Langโ€™์—์„œ ํŒ๋‹จ ํ•ด์ค€๋‹ค.
191
- * โ€˜Textโ€™๋Š” ์˜ํ™” ๋ฆฌ๋ทฐ๋ฅผ ์ž…๋ ฅํ•˜๋Š” ๊ณณ์ด๋‹ค. ์ž…๋ ฅ์„ ๋งˆ์น˜๊ณ  ์ œ์ถœํ•˜๊ธฐ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๊ฒฐ๊ณผ๋ฅผ ๋ถ„์„ํ•  ์ˆ˜ ์žˆ๋‹ค.
192
- """)
193
- gr.Markdown(
194
- """
195
- ### ์ถœ๋ ฅ(Lang, Result, Analysis)์— ๋Œ€ํ•œ ์„ค๋ช…
196
- ๊ฐ€์šด๋ฐ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์˜ค๋ฅธ์ชฝ์— ์žˆ๋Š” ์นธ๋“ค์€ ์ถœ๋ ฅ์— ํ•ด๋‹นํ•œ๋‹ค.
197
- * โ€˜Langโ€™์€ ์™ผ์ชฝ ์ž…๋ ฅ์—์„œ ์–ธ์–ด๋ฅผ ์„ ํƒํ•  ๋•Œ, ํ•œ๊ตญ์–ด๋ฅผ ์„ ํƒํ–ˆ์œผ๋ฉด 100% Kor, ์˜์–ด๋ฅผ ์„ ํƒํ–ˆ๋‹ค๋ฉด 100%% Eng ์ด๋‹ค.
198
- ๋งŒ์•ฝ Default๋ฅผ ์„ ํƒํ–ˆ๋‹ค๋ฉด ํ•œ๊ตญ์–ด์ธ์ง€ ์˜์–ด์ธ์ง€ ํŒ๋‹จ ํ•ด์ค€๋‹ค.
199
- ์ด ๋ฐฉ๋ฒ•์€ [ํ•ด๋‹น ์‚ฌ์ดํŠธ](https://medium.com/@c.chaitanya/language-identification-in-python-using-fasttext-60359dc30ed0)์— ์žˆ๋Š” ํŒจํ‚ค์ง€๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค.
200
- * โ€˜Resultโ€™๋Š” ๋‘ ๋ชจ๋ธ(Kor, Eng)์„ ์ด์šฉํ•ด์„œ ๊ธ์ • ๋ฆฌ๋ทฐ ๋˜๋Š” ๋ถ€์ • ๋ฆฌ๋ทฐ๋ฅผ ํŒ๋‹จํ–ˆ๋‹ค. (๋ชจ๋ธ์— ๋Œ€ํ•ด ๋” ์•Œ๊ณ  ์‹ถ์œผ๋ฉด ๋ฐ‘์—์„œ ํ™•์ธํ•˜๊ธธ ๋ฐ”๋ž€๋‹ค.)
201
- * โ€˜Analysisโ€™๋Š” ์ž…๋ ฅํ•œ ๋ฆฌ๋ทฐ์˜ ๊ธ์ • ๋˜๋Š” ๋ถ€์ •์„ ๊ฒฐ์ •๋  ๋•Œ, ์–ด๋–ค ๋‹จ์–ด์— ์˜ํ•ด์„œ ๊ฒฐ์ • ๋˜์—ˆ๋Š”์ง€ ๊ฐ•์กฐ ํ•ด์ค€๋‹ค.
202
- ์ฆ‰, ์˜ํ–ฅ์„ ์ค€ ๋‹จ์–ด์— ๋Œ€ํ•ด์„œ๋Š” ์–ผ๋งˆ๋‚˜ ๊ธ์ •์ ์ธ(๋˜๋Š” ๋ถ€์ •์ ์ธ) ์˜ํ–ฅ์„ ์ฃผ์—ˆ๋Š”์ง€ ๊ฐ•์กฐ๋˜์–ด ์žˆ๋‹ค.
203
- ( ๊ธ์ •์ธ ๊ฒฝ์šฐ ๋ถ‰์€์ƒ‰(+++, ++, +), ๋ถ€์ •์ธ ๊ฒฝ์šฐ ํŒŒ๋ž€์ƒ‰(---,--,-) )
204
- """)
205
-
206
- with gr.Accordion("๋ชจ๋ธ์— ๋Œ€ํ•œ ์„ค๋ช…"):
207
  gr.Markdown(
208
  """
209
- ' | Kor | Eng
210
- :---:|:---:|:---:
211
- Model Name | klue/roberta-base | bert-base-uncased
212
- Learning Rate | 3e-05 | 5e-5
213
- Batch Size Train | 64 | 64
214
- Steps | 2800 | 2000
215
- Batch Size Test | 4 | 4
216
- Validation Accuracy | 93.55% | 95.81%
217
- Test Accuracy | 94.0% | 92.8%
218
  """)
219
 
220
  with gr.Row():
221
  with gr.Column():
222
- inputs_1 = gr.inputs.Dropdown(['Default', 'Eng', 'Kor'], label='Lang')
223
  inputs_2 = gr.Textbox(placeholder="๋ฆฌ๋ทฐ๋ฅผ ์ž…๋ ฅํ•˜์‹œ์˜ค.", label='Text')
224
  with gr.Row():
225
- btn2 = gr.Button("ํด๋ฆฌ์–ด")
226
  btn = gr.Button("์ œ์ถœํ•˜๊ธฐ")
227
  with gr.Column():
228
  output_1 = gr.Label(num_top_classes=3, label='Lang')
 
165
  # outputs='label',
166
  title=title, description=description, examples=examples)
167
 
168
+
 
169
 
170
  with gr.Blocks() as demo1:
171
  gr.Markdown(
 
177
 
178
  gr.Markdown(
179
  """
180
+ ์˜ํ™” ๋ฆฌ๋ทฐ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด, ๋ฆฌ๋ทฐ๊ฐ€ ๊ธ์ •์ธ์ง€ ๋ถ€์ •์ธ์ง€ ํŒ๋ณ„ํ•ด์ฃผ๋Š” ๋ชจ๋ธ์ด๋‹ค. \
181
+ ์˜์–ด์™€ ํ•œ๊ธ€์„ ์ง€์›ํ•˜๋ฉฐ, ์–ธ์–ด๋ฅผ ์ง์ ‘ ์„ ํƒํ• ์ˆ˜๋„, ํ˜น์€ ๋ชจ๋ธ์ด ์–ธ์–ด๊ฐ์ง€๋ฅผ ์ง์ ‘ ํ•˜๋„๋ก ํ•  ์ˆ˜ ์žˆ๋‹ค.
182
+ ๋ฆฌ๋ทฐ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด, (1) ๊ฐ์ง€๋œ ์–ธ์–ด, (2) ๊ธ์ • ๋ฆฌ๋ทฐ์ผ ํ™•๋ฅ ๊ณผ ๋ถ€์ • ๋ฆฌ๋ทฐ์ผ ํ™•๋ฅ , (3) ์ž…๋ ฅ๋œ ๋ฆฌ๋ทฐ์˜ ์–ด๋Š ๋‹จ์–ด๊ฐ€ ๊ธ์ •/๋ถ€์ • ๊ฒฐ์ •์— ์˜ํ–ฅ์„ ์ฃผ์—ˆ๋Š”์ง€ \
183
+ (๊ธ์ •์ผ ๊ฒฝ์šฐ ๋นจ๊ฐ•์ƒ‰, ๋ถ€์ •์ผ ๊ฒฝ์šฐ ํŒŒ๋ž€์ƒ‰)๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
184
  """)
185
 
186
+ with gr.Accordion(label="๋ชจ๋ธ์— ๋Œ€ํ•œ ์„ค๋ช…", open=False):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  gr.Markdown(
188
  """
189
+ ์˜์–ด ๋ชจ๋ธ์€ bert-base-uncased ๊ธฐ๋ฐ˜์œผ๋กœ, ์˜์–ด ์˜ํ™” ๋ฆฌ๋ทฐ ๋ถ„์„ ๋ฐ์ดํ„ฐ์…‹์ธ SST-2๋กœ ํ•™์Šต ๋ฐ ํ‰๊ฐ€๋˜์—ˆ๋‹ค.
190
+ ํ•œ๊ธ€ ๋ชจ๋ธ์€ klue/roberta-base ๊ธฐ๋ฐ˜์ด๋‹ค. ๊ธฐ์กด ํ•œ๊ธ€ ์˜ํ™” ๋ฆฌ๋ทฐ ๋ถ„์„ ๋ฐ์ดํ„ฐ์…‹์ด ์กด์žฌํ•˜์ง€ ์•Š์•„, ๋„ค์ด๋ฒ„ ์˜ํ™”์˜ ๋ฆฌ๋ทฐ๋ฅผ ํฌ๋กค๋งํ•ด์„œ ์˜ํ™” ๋ฆฌ๋ทฐ ๋ถ„์„ ๋ฐ์ดํ„ฐ์…‹์„ ์ œ์ž‘ํ•˜๊ณ , ์ด๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ชจ๋ธ์„ ํ•™์Šต ๋ฐ ํ‰๊ฐ€ํ•˜์˜€๋‹ค.
191
+ ์˜์–ด ๋ชจ๋ธ์€ SST-2์—์„œ 92.8%, ํ•œ๊ธ€ ๋ชจ๋ธ์€ ๋„ค์ด๋ฒ„ ์˜ํ™” ๋ฆฌ๋ทฐ ๋ฐ์ดํ„ฐ์…‹์—์„œ 94%์˜ ์ •ํ™•๋„๋ฅผ ๊ฐ€์ง„๋‹ค (test set ๊ธฐ์ค€).
192
+ ์–ธ์–ด๊ฐ์ง€๋Š” fasttext์˜ language detector๋ฅผ ์‚ฌ์šฉํ•˜์˜€๋‹ค. ๋ฆฌ๋ทฐ์˜ ๋‹จ์–ด๋ณ„ ์˜ํ–ฅ๋ ฅ์€, ๋‹จ์–ด ๊ฐ๊ฐ์„ ๋ชจ๋ธ์— ๋„ฃ์—ˆ์„ ๋•Œ ๊ฒฐ๊ณผ๊ฐ€ ๊ธ์ •์œผ๋กœ ๋‚˜์˜ค๋Š”์ง€ ๋ถ€์ •์œผ๋กœ ๋‚˜์˜ค๋Š”์ง€๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ์ธก์ •ํ•˜์˜€๋‹ค.
 
 
 
 
 
193
  """)
194
 
195
  with gr.Row():
196
  with gr.Column():
197
+ inputs_1 = gr.Dropdown(choices=['์–ธ์–ด๊ฐ์ง€ ๊ธฐ๋Šฅ ์‚ฌ์šฉ', 'Eng', 'Kor'], value='์–ธ์–ด๊ฐ์ง€ ๊ธฐ๋Šฅ ์‚ฌ์šฉ', label='Lang')
198
  inputs_2 = gr.Textbox(placeholder="๋ฆฌ๋ทฐ๋ฅผ ์ž…๋ ฅํ•˜์‹œ์˜ค.", label='Text')
199
  with gr.Row():
200
+ # btn2 = gr.Button("ํด๋ฆฌ์–ด")
201
  btn = gr.Button("์ œ์ถœํ•˜๊ธฐ")
202
  with gr.Column():
203
  output_1 = gr.Label(num_top_classes=3, label='Lang')