import gradio as gr from transformers import pipeline # Load the text classification model classifier = pipeline('text-classification', model='ardavey/bert-base-ai-generated-text') # Define a function for text classification def classify_text(text): predictions = classifier([text]) label = 'AI Generated Text' if predictions[0]['label'] == 'LABEL_1' else 'Human Generated Text' score = predictions[0]['score'] return f"Prediction: {label}, Score: {score:.4f}" # Create a Gradio interface interface = gr.Interface( fn=classify_text, inputs=gr.Textbox(lines=5, placeholder="Enter your text here..."), outputs="text", title="AI Generated Text Detector", description="Enter a text to check whether the content is written by AI or Human." ) # Launch the Gradio app interface.launch()