Jr0hamza commited on
Commit
296c465
·
verified ·
1 Parent(s): c025fe7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -1,20 +1,23 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load model from Hugging Face
5
- sentiment_pipeline = pipeline("text-classification", model="Jr0hamza/sentiment-analysis-model")
 
6
 
 
7
  def predict_sentiment(text):
8
  result = sentiment_pipeline(text)
9
  return result[0]["label"]
10
 
11
- # Create Gradio UI
12
  interface = gr.Interface(
13
  fn=predict_sentiment,
14
  inputs="text",
15
  outputs="text",
16
- title="Sentiment Analysis Model",
17
- description="Enter text and get sentiment prediction (Positive/Negative)."
18
  )
19
 
 
20
  interface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load the sentiment analysis model
5
+ model_name = "Jr0hamza/sentiment-analysis-model"
6
+ sentiment_pipeline = pipeline("text-classification", model=model_name)
7
 
8
+ # Function to predict sentiment
9
  def predict_sentiment(text):
10
  result = sentiment_pipeline(text)
11
  return result[0]["label"]
12
 
13
+ # Gradio Interface
14
  interface = gr.Interface(
15
  fn=predict_sentiment,
16
  inputs="text",
17
  outputs="text",
18
+ title="Sentiment Analysis",
19
+ description="Enter text to analyze sentiment (Positive/Negative)."
20
  )
21
 
22
+ # Launch the app
23
  interface.launch()