File size: 1,167 Bytes
f824ccf d74ac86 14f73ef 247f8bc 14f73ef f824ccf 247f8bc f824ccf 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 |
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))
|