ningrumdaud commited on
Commit
b25b5d0
·
verified ·
1 Parent(s): b65dde5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -30
app.py CHANGED
@@ -27,33 +27,33 @@ def documentation():
27
  Choose a model from the dropdown and enter text to see the sentiment prediction.
28
  """
29
 
30
- # Define example inputs
31
- exams = [
32
- "I absolutely love this product! It has changed my life.",
33
- "This is the worst movie I have ever seen. Completely disappointing.",
34
- "I'm not sure how I feel about this new update. It has some good points, but also many drawbacks.",
35
- "The customer service was fantastic! Very helpful and polite.",
36
- "Honestly, this was quite a mediocre experience. Nothing special."
37
- ]
38
-
39
- # Setup the tabs for Demo and Documentation
40
- tab1 = gr.Interface(
41
- fn=predict_sentiment,
42
- title="Sentiment Analysis",
43
- description="Select a model and enter text to analyze sentiment.",
44
- inputs=[gr.Textbox(label="Input Text", placeholder="Type here or click an example..."),
45
- gr.Radio(["Model 1 (RoBERTa-large)", "Model 2 (BERTweet)"], label="Model Choice")],
46
- outputs="text",
47
- examples=exams
48
- )
49
-
50
- # Setup the tabs for Documentation
51
- tab2 = gr.Interface(
52
- fn=documentation,
53
- title="Documentation",
54
- inputs=None,
55
- outputs=gr.Markdown()
56
- )
57
-
58
- iface = gr.TabbedInterface([tab1, tab2], ["Demo", "Documentation"])
59
- iface.launch()
 
27
  Choose a model from the dropdown and enter text to see the sentiment prediction.
28
  """
29
 
30
+ with gr.Blocks(title="Sentiment Analysis", theme=gr.themes.Soft()) as demo:
31
+ with gr.Tabs():
32
+ with gr.TabItem("Demo"):
33
+ with gr.Row():
34
+ with gr.Column(scale=2):
35
+ text_input = gr.Textbox(label="Input Text", placeholder="Type here or select an example...")
36
+ model_choice = gr.Radio(["Model 1 (RoBERTa-large)", "Model 2 (BERTweet)"], label="Model Choice", value="Model 1 (RoBERTa-large)")
37
+ submit_button = gr.Button("Analyze")
38
+ with gr.Column():
39
+ output = gr.Label()
40
+
41
+ examples = gr.Examples(examples=[
42
+ "I absolutely love this product! It has changed my life.",
43
+ "This is the worst movie I have ever seen. Completely disappointing.",
44
+ "I'm not sure how I feel about this new update. It has some good points, but also many drawbacks.",
45
+ "The customer service was fantastic! Very helpful and polite.",
46
+ "Honestly, this was quite a mediocre experience. Nothing special."
47
+ ], inputs=text_input)
48
+
49
+ submit_button.click(
50
+ predict_sentiment,
51
+ inputs=[text_input, model_choice],
52
+ outputs=output
53
+ )
54
+
55
+ with gr.TabItem("Documentation"):
56
+ doc_text = gr.Markdown()
57
+ doc_text.update(documentation())
58
+
59
+ demo.launch()