Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
|
|
4 |
sentiment = pipeline('sentiment-analysis')
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
iface.launch()
|
|
|
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")
|
29 |
|
30 |
+
# μΈν°νμ΄μ€ μ€ν
|
31 |
iface.launch()
|