import gradio as gr from huggingface_hub import from_pretrained_fastai from blurr.text.modeling.all import * def predict(text): repo_id = "msivanes/blurr_IMDB_distilbert_cls" learn = from_pretrained_fastai(repo_id) probs = learn.predict(text) return f"Sentiment Prediction Confidence for the sentence '{text}' as positive is {100 * probs[0]['probs'][1]:.2f}%" examples = ['This hack day is amazing', 'I hate the weather today.', 'Loved how Ryan started talking in gibberish language'] demo = gr.Interface(fn=predict, inputs=gr.Textbox(lines=3, label="Input Text"), outputs="text", title='DistiBERT Sentiment Classification', examples=examples) demo.launch()