Haticece commited on
Commit
7d60ca9
·
verified ·
1 Parent(s): 845a0b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -19
app.py CHANGED
@@ -1,22 +1,9 @@
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)
 
 
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()