import pickle import pandas as pd import tensorflow as tf from tensorflow.keras.models import load_model import tensorflow_addons as tfa import numpy as np #loading model loaded_model = tf.keras.models.load_model('model') #data load acts=pd.read_csv('user_acts_one_hot.csv', index_col="Unnamed: 0") acts=acts.drop(["Agent"],axis=1) acts=acts.drop(["Act"],axis=1) #tokenizer polbert from transformers import * tokenizer = BertTokenizer.from_pretrained("dkleczek/bert-base-polish-uncased-v1") input_data = acts["text"].tolist() encoded_input = tokenizer.batch_encode_plus(input_data, padding=True, truncation=True, return_tensors='tf') dataset = tf.data.Dataset.from_tensor_slices({ 'input_ids': encoded_input['input_ids'], 'attention_mask': encoded_input['attention_mask'], 'token_type_ids': encoded_input['token_type_ids'] }).batch(2) # make predictions predictions = loaded_model.predict(dataset) for prediction in predictions: predicted_classes = (predictions[prediction]> 0.5).astype("int32") classes = ["ack","affirm","bye","hello","help","negate","null","repeat","reqalts","reqmore","restart","silence","thankyou","confirm","deny","inform","request"] print(predicted_classes) ## to do - evaluating f score