|
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline |
|
import torch |
|
import pickle |
|
import streamlit as st |
|
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu") |
|
|
|
|
|
|
|
|
|
|
|
classifier = pipeline("zero-shot-classification", model="MoritzLaurer/mDeBERTa-v3-base-mnli-xnli") |
|
|
|
with open('titles_astiko.pkl', 'rb') as file: |
|
titles_astiko = pickle.load(file) |
|
|
|
|
|
|
|
|
|
|
|
def classify(text): |
|
output = classifier(text, titles_astiko, multi_label=True) |
|
return output |
|
|
|
|
|
text = st.text_input('Enter some text:') |
|
if text: |
|
st.text(classify(text)) |