LovnishVerma commited on
Commit
85c04da
1 Parent(s): a3e41d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -1,19 +1,25 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
 
5
 
6
- def summarize_text(input_text):
7
- summary = summarizer(input_text, max_length=150, min_length=50, length_penalty=2.0, num_beams=4, early_stopping=True)
8
- return summary[0]['summary_text']
 
 
 
9
 
 
10
  iface = gr.Interface(
11
- fn=summarize_text,
12
  inputs=gr.Textbox(),
13
  outputs=gr.Textbox(),
14
  live=True,
15
- title="Text Summarization App",
16
- description="Enter a longer document, and the model will generate a summary.",
17
  )
18
 
 
19
  iface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load pre-trained sentiment analysis model
5
+ classifier = pipeline('sentiment-analysis')
6
 
7
+ # Define the sentiment analysis function
8
+ def analyze_sentiment(text):
9
+ result = classifier(text)
10
+ sentiment = result[0]['label']
11
+ confidence = result[0]['score']
12
+ return f"Sentiment: {sentiment}, Confidence: {confidence:.4f}"
13
 
14
+ # Create Gradio interface
15
  iface = gr.Interface(
16
+ fn=analyze_sentiment,
17
  inputs=gr.Textbox(),
18
  outputs=gr.Textbox(),
19
  live=True,
20
+ title="Sentiment Analysis App",
21
+ description="Enter a sentence, and the model will predict its sentiment.",
22
  )
23
 
24
+ # Launch the Gradio app
25
  iface.launch()