Sambhavnoobcoder's picture
software engineer draft
078e4df
raw
history blame
599 Bytes
import gradio as gr
import tensorflow as tf
# Load the saved model
model = tf.keras.models.load_model("sentimentality.h5")
def predict_sentiment(text):
# preprocess input text
processed_text = preprocess(text)
# predict sentiment
prediction = model.predict([processed_text])[0][0]
sentiment = 'positive' if prediction >= 0.5 else 'negative'
return sentiment
iface = gr.Interface(fn=predict_sentiment,
inputs=gr.inputs.Textbox(label='Input Text'),
outputs=gr.outputs.Label(label='Sentiment Prediction'))
iface.launch()