File size: 699 Bytes
f91fdba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)