feat: mvp front
Browse files- app.py +16 -20
- requirements.txt +0 -1
app.py
CHANGED
@@ -1,29 +1,25 @@
|
|
1 |
-
import os
|
2 |
-
from pathlib import Path
|
3 |
-
|
4 |
import streamlit as st
|
5 |
|
6 |
-
x = st.slider('Select a value')
|
7 |
-
st.write(x, 'squared is', x * x)
|
8 |
-
# from huggingface_hub import login
|
9 |
-
|
10 |
-
# login(os.getenv('HF_TOKEN'))
|
11 |
-
|
12 |
-
# hub_folder = Path('~/.cache/huggingface/hub')
|
13 |
-
# for path in hub_folder.walk():
|
14 |
-
# st.write(path)
|
15 |
-
|
16 |
from transformers import AutoModelForSequenceClassification
|
17 |
from transformers import AutoTokenizer
|
18 |
from transformers import TextClassificationPipeline
|
19 |
|
20 |
-
model = AutoModelForSequenceClassification.from_pretrained(
|
21 |
-
"issai/rembert-sentiment-analysis-polarity-classification-kazakh")
|
22 |
-
tokenizer = AutoTokenizer.from_pretrained("issai/rembert-sentiment-analysis-polarity-classification-kazakh")
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
for review in reviews:
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
from transformers import AutoModelForSequenceClassification
|
4 |
from transformers import AutoTokenizer
|
5 |
from transformers import TextClassificationPipeline
|
6 |
|
|
|
|
|
|
|
7 |
|
8 |
+
@st.cache_data()
|
9 |
+
def get_pipe():
|
10 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
11 |
+
"issai/rembert-sentiment-analysis-polarity-classification-kazakh")
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained("issai/rembert-sentiment-analysis-polarity-classification-kazakh")
|
13 |
+
return TextClassificationPipeline(model=model, tokenizer=tokenizer)
|
14 |
+
|
15 |
|
16 |
+
pipe = get_pipe()
|
17 |
+
st.title('KazSandra@ISSAI')
|
18 |
+
st.text('Sentiment Analysis Polarity Classification In Kazakh Language.')
|
19 |
+
input_text = st.text_area('Input text', placeholder='Provide your text', value='Осы кітап қызық сияқты.')
|
20 |
+
# reviews = ["Бұл бейнефильм маған түк ұнамады.", "Осы кітап қызық сияқты."]
|
21 |
|
22 |
+
# for review in reviews:
|
23 |
+
if input_text:
|
24 |
+
out = pipe(input_text)[0]
|
25 |
+
st.text("Label: {label}\nScore: {score}".format(**out))
|
requirements.txt
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
streamlit~=1.37.0
|
2 |
-
huggingface-hub~=0.24.5
|
3 |
torch==2.4.0
|
4 |
torchvision==0.19.0
|
5 |
torchaudio==2.4.0
|
|
|
1 |
streamlit~=1.37.0
|
|
|
2 |
torch==2.4.0
|
3 |
torchvision==0.19.0
|
4 |
torchaudio==2.4.0
|