Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer | |
# Load model and tokenizer | |
model_name = "peterkros/immunization-classification-model" | |
model = AutoModelForSequenceClassification.from_pretrained(model_name) | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
# Define the pipeline | |
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer) | |
def classify_text(text): | |
# Get predictions | |
predictions = classifier(text) | |
return predictions | |
# Create Gradio interface | |
iface = gr.Interface( | |
fn=classify_text, | |
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."), | |
outputs=gr.outputs.JSON(), | |
title="Text Classification with DistilBERT", | |
description="Enter text to classify it using a DistilBERT model trained for text classification." | |
) | |
# Launch the app | |
if __name__ == "__main__": | |
iface.launch() |