Spaces:
Runtime error
Runtime error
File size: 669 Bytes
ef63c47 b7c9865 ef63c47 b7c9865 070bec4 b7c9865 070bec4 b7c9865 daa8e07 ffc2079 b7c9865 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from huggingface_hub import from_pretrained_fastai
import gradio as gr
from fastai.vision.all import *
# repo_id = "YOUR_USERNAME/YOUR_LEARNER_NAME"
repo_id = "isboudja/Spam"
learner = from_pretrained_fastai(repo_id)
labels = learner.dls.vocab
def predict(text):
pred, pred_idx, probs = learner.predict(text)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
# Create and launch the Gradio interface for text input
gr.Interface(
fn=predict,
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
outputs=gr.outputs.Label(),
examples=["WON a guaranteed £1000 cash","Hello, how are you?"]
).launch(share=False) |