Haticece commited on
Commit
b46fba9
·
verified ·
1 Parent(s): 3a020f7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ # Hugging Face modelini yükleyin
5
+ sentiment_model = pipeline("sentiment-analysis")
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
+ # Arayüzü başlatın
22
+ interface.launch(share=True)