File size: 938 Bytes
6e2c108
d98fcb9
 
 
 
 
6e2c108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import streamlit as st
from transformers import (
    AutoModelForSequenceClassification,
    AutoTokenizer,
    pipeline
)

tokenizer = AutoTokenizer.from_pretrained(
    'airesearch/wangchanberta-base-att-spm-uncased'
)
model = AutoModelForSequenceClassification.from_pretrained(
    'airesearch/wangchanberta-base-att-spm-uncased',
    revision='finetuned@wisesight_sentiment-v1.1',
)
text_cls_pipeline = pipeline(task='sentiment-analysis',
                            tokenizer=tokenizer,
                            model=model,
                            return_all_scores=True)

def main():
    st.title("Text")

    with st.form("text_field"):
        text = st.text_area('enter some text:')
        # clicked==True only when the button is clicked
        clicked = st.form_submit_button("Submit")
        if clicked:
          results = text_cls_pipeline([text])
          st.json(results)

if __name__ == "__main__":
    main()