| import gradio as gr |
| from transformers import pipeline |
|
|
| |
| |
| model = pipeline(task="text-classification", model="adrienhongcs/clara-0") |
|
|
| def predict(input_text): |
| |
| predictions = model(input_text) |
| |
| |
| label = predictions[0]["label"] |
| score = predictions[0]["score"] |
| |
| |
| return label, score |
|
|
| |
| gradio_app = gr.Interface( |
| fn=predict, |
| inputs=gr.Textbox(label="Enter a deduction backup doc text"), |
| outputs=[ |
| gr.Textbox(label="Predicted Reason"), |
| gr.Number(label="Confidence 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." |
| ) |
|
|
| |
| if __name__ == "__main__": |
| gradio_app.launch() |