tamatwi commited on
Commit
8108da4
·
verified ·
1 Parent(s): f89b939

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ sentiment_analyzer = pipeline("sentiment-analysis")
5
+
6
+ def analyze_sentiment(text):
7
+ result = sentiment_analyzer(text)[0]
8
+ return f"感情: {result['label']}, 確信度: {result['score']:.2f}"
9
+
10
+ iface = gr.Interface(
11
+ fn=analyze_sentiment,
12
+ inputs="text",
13
+ outputs="text",
14
+ title="簡単な感情分析",
15
+ description="テキストを入力して、その感情を分析します。"
16
+ )
17
+
18
+ iface.launch()