Create app.py
Browse files
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()
|