suinY00N commited on
Commit
b8f6eea
ยท
verified ยท
1 Parent(s): c11d5a6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # ๊ฐ์„ฑ ๋ถ„์„ ํŒŒ์ดํ”„๋ผ์ธ ์ดˆ๊ธฐํ™”
5
+ sentiment = pipeline("sentiment-analysis")
6
+
7
+ # ์‚ฌ์šฉ์ž ์ž…๋ ฅ์— ๋Œ€ํ•œ ๊ฐ์„ฑ ๋ถ„์„ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
8
+ def get_sentiment(์ž…๋ ฅ):
9
+ # ๊ฐ์„ฑ ๋ถ„์„ ์‹คํ–‰
10
+ result = sentiment(์ž…๋ ฅ)
11
+ # ๊ฒฐ๊ณผ ํฌ๋งทํŒ… ๋ฐ ๋ฐ˜ํ™˜
12
+ return result[0]
13
+
14
+ # Gradio ์•ฑ ์ธํ„ฐํŽ˜์ด์Šค ๊ตฌ์„ฑ
15
+ iface = gr.Interface(
16
+ fn=get_sentiment, # ์‹คํ–‰ํ•  ํ•จ์ˆ˜
17
+ inputs=gr.inputs.Textbox(lines=2, placeholder="์—ฌ๊ธฐ์— ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”..."), # ์ž…๋ ฅ๋ž€ ์„ค์ •
18
+ outputs="json", # ์ถœ๋ ฅ ํ˜•ํƒœ
19
+ clear_on_submit=True, # ์ œ์ถœ ํ›„ ์ž…๋ ฅ๋ž€ ํด๋ฆฌ์–ด
20
+ title="ํ…์ŠคํŠธ ๊ฐ์„ฑ ๋ถ„์„", # UI ์ œ๋ชฉ
21
+ description="ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ์ œ์ถœ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜์—ฌ ๊ฐ์„ฑ ๋ถ„์„ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•˜์„ธ์š”." # UI ์„ค๋ช…
22
+ )
23
+
24
+ # Gradio ์•ฑ ์‹คํ–‰
25
+ iface.launch()