mbabazif
commited on
Commit
•
1c790d0
1
Parent(s):
384633a
add Application File
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ import gradio as gr
|
|
9 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
10 |
|
11 |
# Specifying the model path, which points to the Hugging Face Model Hub
|
12 |
-
model_path = f'Mbabazi/
|
13 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
14 |
model = AutoModelForSequenceClassification.from_pretrained(model_path)
|
15 |
|
@@ -34,13 +34,19 @@ def predict_tweet(tweet):
|
|
34 |
|
35 |
# Create a Gradio Interface for the tweet sentiment prediction function
|
36 |
iface = gr.Interface(
|
37 |
-
fn=predict_tweet,
|
38 |
-
inputs="text",
|
39 |
outputs="label", # Specify output type as label
|
40 |
-
title="
|
41 |
-
description="Enter a
|
|
|
|
|
|
|
|
|
|
|
42 |
)
|
43 |
|
|
|
44 |
iface.launch()
|
45 |
|
46 |
# with gr.Blocks() as demo:
|
|
|
9 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
10 |
|
11 |
# Specifying the model path, which points to the Hugging Face Model Hub
|
12 |
+
model_path = f'Mbabazi/cardiffnlp_twitter_roberta_base_sentiment_latest_Nov2023'
|
13 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
14 |
model = AutoModelForSequenceClassification.from_pretrained(model_path)
|
15 |
|
|
|
34 |
|
35 |
# Create a Gradio Interface for the tweet sentiment prediction function
|
36 |
iface = gr.Interface(
|
37 |
+
fn=predict_tweet, # Set the prediction function
|
38 |
+
inputs="text", # Specify input type as text
|
39 |
outputs="label", # Specify output type as label
|
40 |
+
title="Vaccine Sentiment Classifier", # Set the title of the interface
|
41 |
+
description="Enter a text about vaccines to determine if the sentiment is negative, neutral, or positive.", # Provide a brief description
|
42 |
+
examples=[
|
43 |
+
["Vaccinations have been a game-changer in public health, significantly reducing the incidence of many dangerous diseases and saving countless lives."],
|
44 |
+
["Vaccinations are a medical intervention that introduces a vaccine to stimulate an individual’s immune response against a particular disease."],
|
45 |
+
["Vaccines are rushed to the market without proper testing and are pushed by corporations that value profits over the well-being of the public."]
|
46 |
+
]
|
47 |
)
|
48 |
|
49 |
+
|
50 |
iface.launch()
|
51 |
|
52 |
# with gr.Blocks() as demo:
|