Spaces:
Sleeping
Sleeping
import gradio as gr | |
import tensorflow as tf | |
import tensorflow_hub as hub | |
import tensorflow_text as text | |
new_model = tf.keras.models.load_model('my_model.h5', custom_objects={'KerasLayer': hub.KerasLayer}) | |
categories = ('Spam', 'Not Spam') | |
def classify_review(review): | |
if review.strip() != "": | |
prob = new_model.predict([review]) | |
spam_probability = float(prob[0][0]) | |
output_label = f"Probability of being spam: {spam_probability}" | |
return output_label | |
else: | |
return "Enter a review first" | |
review = gr.inputs.Textbox(label="Review") | |
label = gr.outputs.Label() | |
examples = [ | |
"""Congratulations! You have been selected as the lucky winner of our exclusive offer. | |
Get a chance to win a free vacation package by participating in our online survey. | |
Simply click the link below and provide your feedback to qualify for the prize. | |
Hurry, this offer is available for a limited time only. Don't miss out on this amazing opportunity!""", | |
"""Hi [Recipient],I hope this email finds you well. I wanted to inform you about the upcoming | |
team-building event scheduled for next week. We have organized a fun-filled day of activities | |
and games to strengthen team bonds and foster collaboration.Please block your calendar for the | |
event on [Date] from [Time]. It will take place at [Location]. Lunch and snacks will be provided, | |
so you can focus on enjoying the day with your colleagues.We look forward to seeing you there and | |
creating memorable experiences together.""" | |
] | |
intf = gr.Interface(fn=classify_review, inputs=review, outputs=label, examples=examples) | |
if __name__ == "__main__": | |
intf.launch(inline=False, share=True) |