Update app.py
Browse files
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 |
-
|
| 18 |
sentiment = pipeline('sentiment-analysis')
|
| 19 |
|
| 20 |
-
|
| 21 |
def get_sentiment(input_text):
|
| 22 |
-
|
| 23 |
-
|
| 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")
|