File size: 974 Bytes
88d9d61
 
 
debef99
 
 
c64544f
debef99
 
 
c64544f
debef99
c64544f
debef99
c64544f
debef99
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
!pip install transformers gradio sentencepiece
!pip install transformers[sentencepiece]
!pip install sacremoses
import gradio as gr # gradio를 가져와서 쓰는데, 매번 gradio 여섯자 치는게 귀찮으면
# as gr이라고 추가해서 이 이후로는 gr이라고만 써도 됨
# gradio가 웹 상에서의 데모를 만들어줌 (UI 포함!)
import transformers # 트랜스포머(신경망의 일종)
from transformers import pipeline # 파이프라인은 머신러닝 문제를 해결하는 데 필요한
# 여러 구성 요소를 묶어줌 -> 구성 요소란? 예) 문제의 종류, 모델의 종류 등

pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
# 문제의 종류는 번역이고, 우리가 쓸 모델은 Hel.... en이라 불리는 모델
demo = gr.Interface.from_pipeline(pipe)
# gradio라는 라이브러리에 정의되어있는 Interface를 만들자
# 뭐로부터 만드냐면 pipe로부터
# UI -> User Interface
demo.launch()