Spaces:
Runtime error
Runtime error
File size: 803 Bytes
fc6f922 bde3f08 fc6f922 bde3f08 fc6f922 |
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 28 29 30 31 32 33 34 35 |
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() |