Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""demo_gradio_huggingface_spaces.ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1vy72Qs-scdzH68lhYbGN11fLzcE9Md1O
|
8 |
+
"""
|
9 |
+
|
10 |
+
#!pip install transformers gradio sentencepiece
|
11 |
+
#!pip install transformers[sentencepiece]
|
12 |
+
#!pip install sacremoses
|
13 |
+
# gradio ๊ทธ๋ผ๋์ค ๊ทธ๋ ์ด๋์ค
|
14 |
+
# !๋ ์ฝ๋ฉ์๊ฒ ํ๋ ์์คํ
๋ช
๋ น์ด
|
15 |
+
# ์์คํ
๋ช
๋ น์ด?๊ฐ ๋ญ์ฃ : ํค์๋ -> ์ ๋์ค ์ ์คํฌ๋ฆฝํธ ๋ช
๋ น์ด
|
16 |
+
# ! ์์ด๋ ๊ทธ๋ฅ ์ผ๋ฐ ํ์ด์ฌ ๋ช
๋ น์ด
|
17 |
+
# sklearn/pandas/plotly๋ ์ค์น ์ ํ๋๋ฐ?
|
18 |
+
# ์ฝ๋ฉ ๋จธ์ ์ ๊ธฐ๋ณธ์ ์ผ๋ก ์ค์น๋์ด์๋๋ฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ด ์์
|
19 |
+
|
20 |
+
import gradio as gr # gradio๋ฅผ ๊ฐ์ ธ์์ ์ฐ๋๋ฐ, ๋งค๋ฒ gradio ์ฌ์ฏ์ ์น๋๊ฒ ๊ท์ฐฎ์ผ๋ฉด
|
21 |
+
# as gr์ด๋ผ๊ณ ์ถ๊ฐํด์ ์ด ์ดํ๋ก๋ gr์ด๋ผ๊ณ ๋ง ์จ๋ ๋จ
|
22 |
+
# gradio๊ฐ ์น ์์์์ ๋ฐ๋ชจ๋ฅผ ๋ง๋ค์ด์ค (UI ํฌํจ!)
|
23 |
+
import transformers # ํธ๋์คํฌ๋จธ(์ ๊ฒฝ๋ง์ ์ผ์ข
)
|
24 |
+
from transformers import pipeline # ํ์ดํ๋ผ์ธ์ ๋จธ์ ๋ฌ๋ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๋ฐ ํ์ํ
|
25 |
+
# ์ฌ๋ฌ ๊ตฌ์ฑ ์์๋ฅผ ๋ฌถ์ด์ค -> ๊ตฌ์ฑ ์์๋? ์) ๋ฌธ์ ์ ์ข
๋ฅ, ๋ชจ๋ธ์ ์ข
๋ฅ ๋ฑ
|
26 |
+
|
27 |
+
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
|
28 |
+
# ๋ฌธ์ ์ ์ข
๋ฅ๋ ๋ฒ์ญ์ด๊ณ , ์ฐ๋ฆฌ๊ฐ ์ธ ๋ชจ๋ธ์ Hel.... en์ด๋ผ ๋ถ๋ฆฌ๋ ๋ชจ๋ธ
|
29 |
+
demo = gr.Interface.from_pipeline(pipe)
|
30 |
+
# gradio๋ผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์ ์๋์ด์๋ Interface๋ฅผ ๋ง๋ค์
|
31 |
+
# ๋ญ๋ก๋ถํฐ ๋ง๋๋๋ฉด pipe๋ก๋ถํฐ
|
32 |
+
# UI -> User Interface
|
33 |
+
demo.launch()
|
34 |
+
|
35 |