import gradio as gr from transformers import pipeline # Load the HuggingFace text classification model model = pipeline("text-classification", model="textattack/bert-base-uncased-imdb", tokenizer="textattack/bert-base-uncased-imdb") # Define the Gradio interface def classify_text(text): result = model(text)[0] label = result["label"] score = result["score"] return f"Label: {label}, Score: {score}" inputs = gr.inputs.Textbox(lines=5, label="Input Text") outputs = gr.outputs.Textbox(label="Classification Result") gr.Interface(fn=classify_text, inputs=inputs, outputs=outputs).launch()