grimzaeye commited on
Commit
d9a5372
·
verified ·
1 Parent(s): 104205e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -17
app.py CHANGED
@@ -1,28 +1,15 @@
1
- # import gradio as gr
2
- # from transformers import pipeline
3
 
4
- # sentiment = pipeline('sentiment-analysis')
5
-
6
- # # def get_sentiment(input):
7
- # # response =
8
- # def greet(name):
9
- # return "Hello " + name + "!!"
10
-
11
- # iface = gr.Interface(fn=greet, title="Sentiment Analysis", inputs="text", outputs="text")
12
- # iface.launch()
13
 
14
  import gradio as gr
15
  from transformers import pipeline
16
 
17
- # Hugging Face에서 제공하는 sentiment-analysis 파이프라인 로드
18
  sentiment = pipeline('sentiment-analysis')
19
 
20
- # 입력 텍스트에 대해 감정 분석을 수행하는 함수
21
  def get_sentiment(input_text):
22
- # sentiment-analysis 모델을 사용하여 입력 받은 텍스트의 감정을 분석
23
- result = sentiment(input_text)
24
- # 결과는 리스트 형태로 반환되며, 첫 번째 결과의 레이블과 점수를 포맷팅하여 반환
25
- return f"Label: {result[0]['label']}, Score: {result[0]['score']:.2f}"
26
 
27
  # Gradio 인터페이스 설정
28
  iface = gr.Interface(fn=get_sentiment, title="Sentiment Analysis", inputs="text", outputs="text")
 
 
 
1
 
 
 
 
 
 
 
 
 
 
2
 
3
  import gradio as gr
4
  from transformers import pipeline
5
 
6
+
7
  sentiment = pipeline('sentiment-analysis')
8
 
9
+
10
  def get_sentiment(input_text):
11
+ return sentiment(input_text)
12
+
 
 
13
 
14
  # Gradio 인터페이스 설정
15
  iface = gr.Interface(fn=get_sentiment, title="Sentiment Analysis", inputs="text", outputs="text")