Create app.py
Browse files1234567891011121314151617181920212223242526272829303132import tensorflow as tfimport tensorflow_hub as hubimport tensorflow_text as textimport pandas as pdimport tensorflow as tfimport gradio as gr
# Load the SavedModelmodel_path = '/content/drive/MyDrive/BERT/saved_model'loaded_model = tf.saved_model.load(model_path)
# Retrieve the inference function (usually 'serving_default')infer = loaded_model.signatures['serving_default']
def pre_process(input_data): input_tensor = tf.constant(input_data, dtype=tf.string) return input_tensor
def ask(name): data = pre_process(name) predictions = infer(text = data) output_tensor = predictions['output'] op = output_tensor.numpy() if op[0] > 0.5: return "The entered message is related to Banking" else: return "It is a non-banking message. May subject to be SPAM or other messages"
demo = gr.Interface(fn=ask, inputs="text", outputs="text")demo.launch()
app.pyAdded+32