lyly21 commited on
Commit
c60d272
1 Parent(s): 626b9fa

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # sentiment-analysis 파이프라인 로드
5
+ sentiment = pipeline('sentiment-analysis')
6
+
7
+ # 입력을 받아 sentiment-analysis를 수행하는 함수
8
+ def get_sentiment(text):
9
+ # 입력 텍스트에 대한 sentiment-analysis를 수행하고 결과 반환
10
+ result = sentiment(text)
11
+ return result[0]['label']
12
+
13
+ # Gradio UI를 생성합니다.
14
+ gr.Interface(
15
+ fn=get_sentiment,
16
+ inputs="text",
17
+ outputs="text",
18
+ title="Sentiment Analysis",
19
+ " # UI의 설명을 설정합니다.
20
+ ).launch() # UI를 실행합니다.