# -*- coding: utf-8 -*- """demo_gradio_huggingface_spaces.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1vy72Qs-scdzH68lhYbGN11fLzcE9Md1O """ #!pip install transformers gradio sentencepiece #!pip install transformers[sentencepiece] #!pip install sacremoses # gradio 그라디오 그레이디오 # !는 코랩에게 하는 시스템 명령어 # 시스템 명령어?가 뭐죠: 키워드 -> 유닉스 쉘 스크립트 명령어 # ! 없이는 그냥 일반 파이썬 명령어 # sklearn/pandas/plotly는 설치 안 했는데? # 코랩 머신에 기본적으로 설치되어있는데 라이브러리들이 있음 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() # soarhigh0714@gmail.com