Muhammad Anas Akhtar commited on
Commit
24d333a
·
verified ·
1 Parent(s): 274ed02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -3,12 +3,12 @@ import gradio as gr
3
  from transformers import pipeline
4
 
5
  # Initialize the sentiment-analysis pipeline
6
- semantic_analysis = pipeline("sentiment-analysis", model="BAAI/bge-reranker-v2-m3")
7
 
8
- # Define a function to analyze text semantics
9
- def analyze_semantics(input_text):
10
  # Get the result from the pipeline
11
- result = semantic_analysis(input_text)
12
  # Extract label (e.g., Positive/Negative) and confidence score
13
  label = result[0]['label']
14
  confidence = round(result[0]['score'] * 100, 2)
@@ -18,11 +18,11 @@ def analyze_semantics(input_text):
18
  gr.close_all()
19
 
20
  Demo = gr.Interface(
21
- fn=analyze_semantics,
22
- inputs=[gr.Textbox(label="Enter Text for Semantic Analysis", lines=5)],
23
- outputs=[gr.Textbox(label="Semantic Analysis Result", lines=2)],
24
- title="Semantic Analysis App",
25
- description="This application performs semantic analysis to determine the sentiment of the given text."
26
  )
27
 
28
  # Launch the app with a public link
 
3
  from transformers import pipeline
4
 
5
  # Initialize the sentiment-analysis pipeline
6
+ sentiment_analysis = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
7
 
8
+ # Define a function to analyze text sentiment
9
+ def analyze_sentiment(input_text):
10
  # Get the result from the pipeline
11
+ result = sentiment_analysis(input_text)
12
  # Extract label (e.g., Positive/Negative) and confidence score
13
  label = result[0]['label']
14
  confidence = round(result[0]['score'] * 100, 2)
 
18
  gr.close_all()
19
 
20
  Demo = gr.Interface(
21
+ fn=analyze_sentiment,
22
+ inputs=[gr.Textbox(label="Enter Text for Sentiment Analysis", lines=5)],
23
+ outputs=[gr.Textbox(label="Sentiment Analysis Result", lines=2)],
24
+ title="Sentiment Analysis App",
25
+ description="This application performs sentiment analysis to determine whether the text is positive or negative."
26
  )
27
 
28
  # Launch the app with a public link