Spaces:
Runtime error
Runtime error
pip install transformers[tf-cpu] | |
import gradio as gr | |
import tensorflow as tf | |
import numpy as np | |
import pickle | |
# Load model, including its weights and the optimizer | |
model = tf.keras.models.load_model('core4.h5') | |
# load tokenizer | |
with open('tokenizer.pickle', 'rb') as handle: | |
tokenize = pickle.load(handle) | |
text_labels = ['How to apply', 'how much can I get', 'who can apply'] | |
# model.summary() # model architecture | |
def greet(name): | |
tokenizedText = tokenize.texts_to_matrix([string]) | |
prediction = model.predict(np.array([tokenizedText[0]])) | |
predicted_label = text_labels[np.argmax(prediction)] | |
print(prediction[0][np.argmax(prediction)]) | |
print("Predicted label: " + predicted_label + "\n") | |
return predicted_label | |
#One testing case | |
iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
iface.launch() |