import gradio as gr import pickle from keras.models import load_model model = load_model("model.keras") with open("tokenizer.pckl", "rb") as file: tokenizer = pickle.load(file) def classify(text: str, response: str): question = list(tokenizer.texts_to_sequences([q.lower(),])[0]) answer = list(tokenizer.texts_to_sequences([a.lower(),])[0]) arr = np.array([(list(question)+[0,]*l1)[:l1]+(list(answer)+[0,]*l2)[:l2],]) prediction = model.predict(arr)[0][0] if prediction > 0.9: return "Surely relevant "+str(prediction) elif prediction > 0.5: return "Relevant "+str(prediction) elif prediction > 0.1: return "Probably relevant "+str(prediction) else: return "Irrelevant "+str(prediction) iface = gr.Interface(fn=pwcheck, inputs=["text", "text"], outputs="text") iface.launch()