Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,9 @@
|
|
| 1 |
-
from transformers import pipeline
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
# Modeli çalıştıracak bir fonksiyon tanımlayın
|
| 8 |
-
def analyze_sentiment(text):
|
| 9 |
-
result = sentiment_model(text)[0]
|
| 10 |
-
label = result['label']
|
| 11 |
-
score = result['score']
|
| 12 |
-
return f"Sentiment: {label} (Confidence: {score:.2f})"
|
| 13 |
-
|
| 14 |
-
# Gradio arayüzü
|
| 15 |
-
interface = gr.Interface(
|
| 16 |
-
fn=analyze_sentiment,
|
| 17 |
-
inputs=gr.Textbox(label="Enter Text"),
|
| 18 |
-
outputs=gr.Textbox(label="Sentiment Analysis Result")
|
| 19 |
-
)
|
| 20 |
|
| 21 |
-
|
| 22 |
-
interface.launch(
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
def sentiment_analysis(text):
|
| 5 |
+
classifier = pipeline('sentiment-analysis')
|
| 6 |
+
return classifier(text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
interface = gr.Interface(fn=sentiment_analysis, inputs="text", outputs="json")
|
| 9 |
+
interface.launch()
|