MissChloe commited on
Commit
5e5f995
·
1 Parent(s): 9cf7115

Upload 3 files

Browse files
Files changed (3) hide show
  1. THE_BERT_MODEL.ipynb +0 -0
  2. app (1).py +27 -0
  3. requirements (1).txt +3 -0
THE_BERT_MODEL.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
app (1).py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import transformers as pipeline
3
+ from transformers import AutoTokenizer,AutoModelForSequenceClassification
4
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
5
+
6
+ model_name = "Sonny4Sonnix/twitter-roberta-base-sentimental-analysis-of-covid-tweets" # Replace with the name of the pre-trained model you want to use
7
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
8
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
9
+
10
+ sentiment = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
11
+
12
+ def get_sentiment(input_text):
13
+ return sentiment(input_text)
14
+
15
+
16
+
17
+ #Function to predict sentiments from the input text using the model
18
+ prediction = model.predict([text])[0]
19
+ if label==-1:
20
+ return "Negative"
21
+ elif label== 0:
22
+ return "Neutral"
23
+ else:
24
+ return "Positive"
25
+
26
+ iface = gr.Interface(fn=get_sentiment,title="Sentimental Analysis", inputs="text",outputs="text")
27
+ iface.launch(inline=True)
requirements (1).txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ gradio
3
+ torch