File size: 994 Bytes
12ba4ff 52f43c9 0dc3afb 52f43c9 805f6fe fad8a16 52f43c9 46cd5e7 b93d861 46cd5e7 d9d80a0 bedfda3 255991b 805f6fe 52f43c9 |
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 |
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")
# model_name = "MoritzLaurer/mDeBERTa-v3-base-mnli-xnli"
# tokenizer = AutoTokenizer.from_pretrained(model_name)
# model = AutoModelForSequenceClassification.from_pretrained(model_name)
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)
# titles_astiko = ["γάμος", "αλλοδαπός", "φορολογία", "κληρονομικά", "στέγη", "οικογενειακό", "εμπορικό","κλοπή","απάτη"]
def classify(text):
output = classifier(text, titles_astiko, multi_label=True)
return output
text = st.text_input('Enter some text:') # Input field for new text
if text:
st.text(classify(text)) |