adrienhong's picture
Update title
241aaa7
import gradio as gr
from transformers import pipeline
# Load a text classification model
# Replace with your model's path or Hugging Face model name
model = pipeline(task="text-classification", model="adrienhongcs/clara-0")
def predict(input_text):
# Get predictions from the model
predictions = model(input_text)
# Extract the label and score
label = predictions[0]["label"]
score = predictions[0]["score"]
# Return the label and score
return label, score
# Create the Gradio interface
gradio_app = gr.Interface(
fn=predict, # Function to call
inputs=gr.Textbox(label="Enter a deduction backup doc text"), # Text input
outputs=[
gr.Textbox(label="Predicted Reason"), # Output for the label
gr.Number(label="Confidence Score") # Output for the score
],
title="Clara the reason classifier (clara-0, trained on 8000 rows)",
description="Enter a deduction backup (as text) to classify it and get the predicted label and confidence score."
)
# Launch the app
if __name__ == "__main__":
gradio_app.launch()