AnkitAI commited on
Commit
6943fba
1 Parent(s): 4f1a3c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -15
app.py CHANGED
@@ -31,8 +31,6 @@
31
  # # Launch the interface
32
  # interface.launch()
33
 
34
-
35
-
36
  import gradio as gr
37
  from transformers import RobertaForSequenceClassification, RobertaTokenizer
38
  import torch
@@ -74,18 +72,17 @@ css = """
74
  """
75
 
76
  # Create a Gradio interface
77
- interface = gr.Interface(
78
- fn=predict_sentiment,
79
- inputs=gr.inputs.Textbox(lines=5, placeholder="Enter a review...", label="Review Text"),
80
- outputs=gr.outputs.Textbox(label="Sentiment"),
81
- title="Reviews Sentiment Analysis with RoBERTa",
82
- description="Analyze the sentiment of reviews using a fine-tuned RoBERTa model. Enter a review to see if it is positive or negative.",
83
- theme="default",
84
- css=css,
85
- examples=[["This product is great!"], ["I am very disappointed with this purchase."]],
86
- allow_flagging="never"
87
- )
88
 
 
89
 
90
- # Launch the interface
91
- interface.launch()
 
31
  # # Launch the interface
32
  # interface.launch()
33
 
 
 
34
  import gradio as gr
35
  from transformers import RobertaForSequenceClassification, RobertaTokenizer
36
  import torch
 
72
  """
73
 
74
  # Create a Gradio interface
75
+ with gr.Blocks(css=css) as demo:
76
+ gr.Markdown("# Sentiment Analysis with RoBERTa")
77
+ gr.Markdown("Analyze the sentiment of Amazon reviews using a fine-tuned RoBERTa model. Enter a review to see if it is positive or negative. **LABEL_1 = Positive** and **LABEL_0 = Negative**.")
78
+
79
+ with gr.Row():
80
+ with gr.Column():
81
+ input_text = gr.Textbox(lines=5, placeholder="Enter a review...", label="Review Text")
82
+ submit_btn = gr.Button("Analyze")
83
+ with gr.Column():
84
+ output_text = gr.Textbox(label="Sentiment")
 
85
 
86
+ submit_btn.click(predict_sentiment, inputs=input_text, outputs=output_text)
87
 
88
+ demo.launch()