Spaces:
Build error
Build error
Download app.py from adrienhongcs/reason_classification_space: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/spaces/adrienhongcs/reason_classification_space/resolve/main/app.py
- Command line
-
hf download hf://spaces/adrienhongcs/reason_classification_space/app.py
-
curl -L -o app.py https://huggingface.co/spaces/adrienhongcs/reason_classification_space/resolve/main/app.py
1.09 kB
| 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() |