from pathlib import Path import streamlit as st from transformers import AutoModelForSequenceClassification from transformers import AutoTokenizer from transformers import TextClassificationPipeline @st.cache_data() def get_pipe(): 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')) input_text = st.text_area('Input text', placeholder='Provide your text', value='Осы кітап қызық сияқты.') # reviews = ["Бұл бейнефильм маған түк ұнамады.", "Осы кітап қызық сияқты."] pipe = get_pipe() # for review in reviews: if input_text: out = pipe(input_text)[0] st.text("Label: {label}\nScore: {score}".format(**out))