Yah216's picture
Create app.py
f91fdba
raw
history blame
699 Bytes
import streamlit as st
import tensorflow as tf
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("Yah216/Sentiment_Analysis_CAMelBERT_msa_sixteenth_HARD")
model = TFAutoModelForSequenceClassification.from_pretrained("Yah216/Sentiment_Analysis_CAMelBERT_msa_sixteenth_HARD")
labels= model.config.label2id
text = st.text_area("Enter some text!")
if text:
out = tf.math.softmax(model(tokenizer(raw_inputs, padding=True, truncation=True, return_tensors="np")).logits, , axis = -1)
res = out.numpy()
labels['NEGATIVE'] = res[0,0]
labels['NEUTRAL'] = res[0,1]
labels['POSITIVE'] = res[0,2]
st.json(labels)