soarhigh commited on
Commit
d7b2270
โ€ข
1 Parent(s): 4cd2ef6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr # gradio๋ฅผ ๊ฐ€์ ธ์™€์„œ ์“ฐ๋Š”๋ฐ, ๋งค๋ฒˆ gradio ์—ฌ์„ฏ์ž ์น˜๋Š”๊ฒŒ ๊ท€์ฐฎ์œผ๋ฉด
2
+ # as gr์ด๋ผ๊ณ  ์ถ”๊ฐ€ํ•ด์„œ ์ด ์ดํ›„๋กœ๋Š” gr์ด๋ผ๊ณ ๋งŒ ์จ๋„ ๋จ
3
+ # gradio๊ฐ€ ์›น ์ƒ์—์„œ์˜ ๋ฐ๋ชจ๋ฅผ ๋งŒ๋“ค์–ด์คŒ (UI ํฌํ•จ!)
4
+ import transformers # ํŠธ๋žœ์Šคํฌ๋จธ(์‹ ๊ฒฝ๋ง์˜ ์ผ์ข…)
5
+ from transformers import pipeline # ํŒŒ์ดํ”„๋ผ์ธ์€ ๋จธ์‹ ๋Ÿฌ๋‹ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐ ํ•„์š”ํ•œ
6
+ # ์—ฌ๋Ÿฌ ๊ตฌ์„ฑ ์š”์†Œ๋ฅผ ๋ฌถ์–ด์คŒ -> ๊ตฌ์„ฑ ์š”์†Œ๋ž€? ์˜ˆ) ๋ฌธ์ œ์˜ ์ข…๋ฅ˜, ๋ชจ๋ธ์˜ ์ข…๋ฅ˜ ๋“ฑ
7
+
8
+ pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
9
+ # ๋ฌธ์ œ์˜ ์ข…๋ฅ˜๋Š” ๋ฒˆ์—ญ์ด๊ณ , ์šฐ๋ฆฌ๊ฐ€ ์“ธ ๋ชจ๋ธ์€ Hel.... en์ด๋ผ ๋ถˆ๋ฆฌ๋Š” ๋ชจ๋ธ
10
+ demo = gr.Interface.from_pipeline(pipe)
11
+ # gradio๋ผ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ์ •์˜๋˜์–ด์žˆ๋Š” Interface๋ฅผ ๋งŒ๋“ค์ž
12
+ # ๋ญ๋กœ๋ถ€ํ„ฐ ๋งŒ๋“œ๋ƒ๋ฉด pipe๋กœ๋ถ€ํ„ฐ
13
+ # UI -> User Interface
14
+ demo.launch()