kedimestan's picture
Create app.py
d10f97a verified
raw
history blame contribute delete
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()