Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import tensorflow as tf
|
3 |
+
|
4 |
+
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
|
5 |
+
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained("Yah216/Sentiment_Analysis_CAMelBERT_msa_sixteenth_HARD")
|
7 |
+
|
8 |
+
model = TFAutoModelForSequenceClassification.from_pretrained("Yah216/Sentiment_Analysis_CAMelBERT_msa_sixteenth_HARD")
|
9 |
+
|
10 |
+
labels= model.config.label2id
|
11 |
+
|
12 |
+
text = st.text_area("Enter some text!")
|
13 |
+
if text:
|
14 |
+
out = tf.math.softmax(model(tokenizer(raw_inputs, padding=True, truncation=True, return_tensors="np")).logits, , axis = -1)
|
15 |
+
res = out.numpy()
|
16 |
+
|
17 |
+
labels['NEGATIVE'] = res[0,0]
|
18 |
+
labels['NEUTRAL'] = res[0,1]
|
19 |
+
labels['POSITIVE'] = res[0,2]
|
20 |
+
st.json(labels)
|