Spaces:
Runtime error
Runtime error
import tensorflow_hub as hub | |
import pickle | |
import sklearn | |
embed = hub.load("https://tfhub.dev/google/universal-sentence-encoder/4") | |
with open('./model.pck', 'rb') as f: | |
model = pickle.load(f) | |
import gradio as gr | |
def convert(text): | |
#Se genera el embedding del texto | |
text_embed = embed([text]) | |
#El modelo hace su predicción | |
prediction = model.predict_proba(text_embed).flatten() | |
#Se devuelve el percentaje que el modelo ha predicho para cada etiqueta | |
return {"ham": float(prediction[0]), "spam" : float(prediction[1])} | |
iface = gr.Interface( | |
fn=convert, | |
inputs="text", | |
outputs="label", | |
examples=["I will help you win the lottery, my friend", "Please, darling, could you pick up the kids from school today?"], | |
title="Ham or spam?", | |
description="Copy and paste the text message you just received and we'll let you know if it is ham or spam", | |
) | |
iface.launch() |