update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,3 @@
|
|
1 |
-
# app.py
|
2 |
import gradio as gr
|
3 |
-
from transformers import DistilBertTokenizer, DistilBertForSequenceClassification
|
4 |
|
5 |
-
|
6 |
-
tokenizer = DistilBertTokenizer.from_pretrained(model_name)
|
7 |
-
model = DistilBertForSequenceClassification.from_pretrained(model_name)
|
8 |
-
|
9 |
-
def predict_sentiment(text):
|
10 |
-
# Tokenize and predict
|
11 |
-
inputs = tokenizer(text, return_tensors="pt")
|
12 |
-
outputs = model(**inputs)
|
13 |
-
logits = outputs.logits
|
14 |
-
predicted_class = logits.argmax().item()
|
15 |
-
|
16 |
-
# Return the predicted class
|
17 |
-
return {"positive": logits[0][1].item(), "negative": logits[0][0].item()}
|
18 |
-
|
19 |
-
iface = gr.Interface(
|
20 |
-
fn=predict_sentiment,
|
21 |
-
inputs=gr.Textbox(),
|
22 |
-
outputs="label",
|
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
+
gr.Interface.load("models/SamLowe/roberta-base-go_emotions").launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|