mohd43 commited on
Commit
7222a71
·
verified ·
1 Parent(s): 225a9a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -1,20 +1,21 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- pipeline =pipeline("text-classification",model="ProsusAI/finbert",trust_remote_code=True)
 
5
 
6
- def predict(input_img):
7
- predictions = pipeline(input_img , threshold=0.5, #optional parameter defaults to 0
8
- return_scores = False #optional parameter defaults to False
9
- )
10
- return predictions
11
 
 
12
  gradio_app = gr.Interface(
13
  predict,
14
- inputs=gr.Textbox(label="Write a text") ,
15
- outputs=gr.Text(),
16
- title="sentiment analysis",
17
  )
18
 
 
19
  if __name__ == "__main__":
20
  gradio_app.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load the text classification pipeline
5
+ pipeline = pipeline("text-classification", model="ProsusAI/finbert", trust_remote_code=True)
6
 
7
+ def predict(input_text): # Corrected argument name
8
+ predictions = pipeline(input_text, threshold=0.5, return_scores=False)
9
+ return predictions[0] # Extract the first prediction
 
 
10
 
11
+ # Define the Gradio interface
12
  gradio_app = gr.Interface(
13
  predict,
14
+ inputs=gr.Textbox(label="Write a text"),
15
+ outputs=gr.Textbox(label="Predicted Sentiment"), # More descriptive label
16
+ title="Financial Sentiment Analysis", # More specific title
17
  )
18
 
19
+ # Launch the Gradio interface
20
  if __name__ == "__main__":
21
  gradio_app.launch()