Spaces:
Runtime error
Runtime error
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 | |
# Define a function to make predictions | |
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 | |
gr.Interface( | |
fn=predict, | |
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."), | |
outputs=gr.outputs.Label(), | |
examples=["Hello, how are you?", "You won a prize! Click here to claim."] | |
).launch(share=False) |