File size: 1,378 Bytes
a1fa344
f824ccf
 
d74ac86
 
14f73ef
 
 
 
 
247f8bc
a1fa344
247f8bc
 
 
 
 
14f73ef
242bc2f
f824ccf
 
 
 
 
 
a1fa344
 
 
 
 
 
 
 
 
 
 
 
247f8bc
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
33
34
35
36
37
38
39
from operator import setitem
from pathlib import Path

import streamlit as st

from transformers import AutoModelForSequenceClassification
from transformers import AutoTokenizer
from transformers import TextClassificationPipeline


@st.cache_data()
def load_model():
    model = AutoModelForSequenceClassification.from_pretrained(
        "issai/rembert-sentiment-analysis-polarity-classification-kazakh")
    tokenizer = AutoTokenizer.from_pretrained("issai/rembert-sentiment-analysis-polarity-classification-kazakh")
    return TextClassificationPipeline(model=model, tokenizer=tokenizer)


st.title('KazSAnDRA')
static_folder = Path(__file__).parent / 'static'
assert static_folder.exists()

st.write((static_folder / 'description.txt').read_text())
st.image(str(static_folder / 'kazsandra.jpg'))

pipe = load_model()

with st.form('main_form'):
    input_text = st.text_area('Input text', placeholder='Provide your text, e.g. "Осы кітап қызық сияқты".')
    is_submitted = st.form_submit_button(label='Submit')
    if is_submitted:
        if input_text:
            out = pipe(input_text)[0]
            st.text("Label: {label}\nScore: {score}".format(**out))
        else:
            st.text("Please provide your text first.")

# reviews = ["Бұл бейнефильм маған түк ұнамады.", "Осы кітап қызық сияқты."]