Download app.py from AbraMuhara/Fine-TunedBERTURKOfansifTespitServer: direct link, hf CLI and curl.
- Browser
- Download file 872 Bytes
-
https://huggingface.co/spaces/AbraMuhara/Fine-TunedBERTURKOfansifTespitServer/resolve/main/app.py
- Command line
-
hf download hf://spaces/AbraMuhara/Fine-TunedBERTURKOfansifTespitServer/app.py
-
curl -L -o app.py https://huggingface.co/spaces/AbraMuhara/Fine-TunedBERTURKOfansifTespitServer/resolve/main/app.py
872 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the model and tokenizer | |
| classifier = pipeline("text-classification",model="AbraMuhara/Fine-TunedBERTURKOfansifTespit") | |
| # Define the prediction function | |
| def classify_text(text): | |
| # Use the pipeline to classify the text | |
| result = classifier(text) | |
| # Extract the label and score | |
| label = result[0]['label'] | |
| score = result[0]['score'] | |
| return f"Label: {label}\nScore: {score:.4f}" | |
| # Create the Gradio interface | |
| iface = gr.Interface( | |
| fn=classify_text, # The function to call for predictions | |
| inputs=gr.Textbox(), # Text input box | |
| outputs=gr.Text(), # Text output box | |
| title="Text Classification", # Title of the app | |
| description="Enter text to classify it and get the prediction label and score." # Description | |
| ) | |
| # Launch the interface | |
| iface.launch() | |