barbieheimer commited on
Commit
893b93a
1 Parent(s): 906b41b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -26
app.py CHANGED
@@ -1,26 +0,0 @@
1
- # here are some examples for sadness, joy, anger, and optimism.
2
- import gradio as gr
3
- # Load model directly
4
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
5
- from transformers import pipeline
6
-
7
- tokenizer = AutoTokenizer.from_pretrained("barbieheimer/MND_TweetEvalBert_model")
8
- model = AutoModelForSequenceClassification.from_pretrained("barbieheimer/MND_TweetEvalBert_model")
9
-
10
- # We can now use the model in the pipeline.
11
- classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
12
-
13
- def predict(prompt):
14
- completion = classifier(prompt)
15
- return completion[0]["label"], completion[0]["score"]
16
-
17
- examples = [
18
- ["The movie was a bummer."],
19
- ["I cannot wait to watch all these movies!"],
20
- ["The ending of the movie really irks me, gives me the ick fr."],
21
- ["The protagonist seems to have a lot of hope...."]
22
- ]
23
-
24
- gr.Interface.load("models/barbieheimer/MND_TweetEvalBert_model", fn=predict, title="Sentiment Analysis", examples=examples,
25
- inputs=gr.inputs.Textbox(lines=5, label="Paste an Article here."),
26
- outputs=[gr.outputs.Textbox(label="Label"),gr.outputs.Textbox(label="Score")],).launch()