quocviethere commited on
Commit
4a04a3d
1 Parent(s): 1b6d080

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -15
app.py CHANGED
@@ -1,20 +1,15 @@
1
  import gradio as gr
 
2
 
3
- def predict_sentiment(text):
4
- model_output = gr.load("models/quocviethere/roberta-sentiment-model").process(text)
5
- # Convert the model output to a more readable format
6
- if model_output[0] > model_output[1]: # Assuming index 0 is for negative sentiment
7
- return "Negative Review", model_output[0]
8
- else:
9
- return "Positive Review", model_output[1]
10
 
11
- iface = gr.Interface(
12
- fn=predict_sentiment,
13
- inputs=gr.Textbox(lines=2, placeholder="Type your review here"), # define the text input
14
- outputs=gr.Label(num_top_classes=2) # define the output as a label
15
- )
16
-
17
- # Launch the interface
18
- iface.launch()
19
 
 
 
 
 
 
20
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ sentiment = pipeline("sentiment-analysis")
 
 
 
 
 
 
5
 
6
+ def get_sentiment(input_text):
7
+ return sentiment(input_text)
 
 
 
 
 
 
8
 
9
+ iface = gr.Interface(fn = get_sentiment,
10
+ inputs = "text",
11
+ outputs = ['text'],
12
+ title='Sentiment Analysis',
13
+ description = "get sentiment")
14
 
15
+ iface.launch(inline = False)